AngularJS select example
Both ng-options and ng-repeater
HTML
<div ng-app="myApp">
<div ng-controller="AppCtrl">
{{message}} <br />
<!--Options value is defualt 0, 1 ... and it's non change able -->
<span>Default Otions:</span>
<select ng-model="mail_notification" ng-options="c.key as c.value for c in mail_notifications" ng-init = "c.default = 'Y'"></select>
<br />
</div>
</div>
JavaScript
'use strict';
var app = angular.module('myApp', []);
app.controller('AppCtrl', function($scope){
$scope.mail_notifications = [
{
"key": "1",
"value": "First",
"default":"N"
},
{
"key": "only_my_events",
"value": "Default",
"default":"Y"
},
{
"key": "only_assigned",
"value": "Second",
"default":"N"
},
{
"key": "only_owner",
"value": "Third",
"default":"N"
},
{
"key": "none",
"value": "Fourth",
"default":"N"
}
];
$scope.mail_notification = 'all';
$scope.message = "AngularJS select example";
});