This repository has been archived by the owner on Apr 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 27.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(select): match options by expression other than object identity
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.
- Loading branch information
1 parent
4acc28a
commit c32a859
Showing
2 changed files
with
80 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
c32a859
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So glad this made it in!