Last active
August 29, 2015 14:07
-
-
Save sondreb/159a9292f4b681106842 to your computer and use it in GitHub Desktop.
Two examples of binding JSON-annotated object with select in HTML using AngularJS
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
$scope.sort = 'relevance'; | |
$scope.sorting = { | |
'relevance': 'Relevant', | |
'date-posted-desc': 'Recent', | |
'interestingness-desc': 'Interesting' | |
}; | |
$scope.sorting2 = [ | |
{'id': 'relevance', 'text': 'Relevant'}, | |
{ 'id': 'date-posted-desc', 'text': 'Recent'}, | |
{ 'id': 'interestingness-desc', 'text': 'Interesting'} | |
]; | |
<!-- No options is rendered if ng-models is missing. --> | |
<select ng-model="sort" ng-options="k as v for (k,v) in sorting"></select> | |
<select ng-model="sort" ng-options="sort.id as sort.text for sort in sorting2"></select> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment