mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-03-17 07:40:22 +00:00
Extend ng-options with a new clause, "track by [trackByExpression]", which can be used when
working with objects. The `trackByExpression` should uniquely identify select options objects.
This solves the problem of previously having to match ng-options objects by identity.
You can now write: `ng-options="obj as obj.name for obj in objects track by obj.id"`
The "track by" expression will be used when checking for equality of objects.
Examples:
<select
ng-model="user.favMovieStub"
ng-options="movie as movie.name for movie in movies track by movie.id">
</select>
scope: {
user: { name: 'Test user', favMovieStub: { id: 1, name: 'Starwars' } }
movies: [{ id: 1, name: 'Starwars', rating: 5, ... }, { id: 13, ... }]
}
The select input will match user favMovieStub to the first movie in the movies array, and show
"Star Wars" as the selected item.
|
||
|---|---|---|
| .. | ||
| aSpec.js | ||
| booleanAttrsSpec.js | ||
| formSpec.js | ||
| inputSpec.js | ||
| ngBindSpec.js | ||
| ngClassSpec.js | ||
| ngClickSpec.js | ||
| ngCloakSpec.js | ||
| ngControllerSpec.js | ||
| ngCspSpec.js | ||
| ngEventDirsSpec.js | ||
| ngIfSpec.js | ||
| ngIncludeSpec.js | ||
| ngInitSpec.js | ||
| ngKeySpec.js | ||
| ngNonBindableSpec.js | ||
| ngPluralizeSpec.js | ||
| ngRepeatSpec.js | ||
| ngShowHideSpec.js | ||
| ngSrcSpec.js | ||
| ngStyleSpec.js | ||
| ngSwitchSpec.js | ||
| ngViewSpec.js | ||
| scriptSpec.js | ||
| selectSpec.js | ||
| styleSpec.js | ||