Last active
August 29, 2015 14:11
-
-
Save rlfrahm/58c673c4786c88c233dc to your computer and use it in GitHub Desktop.
AngularJs ngOptions for array and object types
This file contains hidden or 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
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css"> | |
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.0/angular.min.js"></script> | |
<script> | |
angular.module('app', []) | |
.controller('AppCtrl', ['$scope',function($scope) { | |
$scope.array = [{label:'Label 1'},{label:'Label 2'},{label:'Label 3'}]; | |
$scope.object = {item1:{label:'Label 1'},item2:{label:'Label 2'},item3:{label:'Label 3'}}; | |
}]); | |
</script> | |
<body ng-app="app" ng-controller="AppCtrl"> | |
<select class="form-control" ng-options="item.label for item in array" ng-model="selectedArrayItem"></select> | |
<select class="form-control" ng-options="item.label for (key,item) in object" ng-model="selectedObjectItem"></select> | |
</body> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment