AngularJS select example

Both ng-options and ng-repeater

by gargdeendayal

HTML

<div ng-app="myApp">
    <div ng-controller="AppCtrl">
        
        <select ng-model="mail_notification" ng-options="c.key as c.value for c in mail_notifications"></select>
                  
    </div>
</div>

JavaScript

'use strict';

var app = angular.module('myApp', []);
app.controller('AppCtrl', function($scope){
    $scope.mail_notifications = [
        {
            "key": "all",
            "value": "For any event on all my projects"
        },
        {
            "key": "selected",
            "value": "For any event on the selected projects only..."
        },
        {
            "key": "only_my_events",
            "value": "Only for things I watch or I'm involved in"
        },
        {
            "key": "only_assigned",
            "value": "Only for things I am assigned to"
        },
        {
            "key": "only_owner",
            "value": "Only for things I am the owner of"
        },
        {
            "key": "none",
            "value": "No events"
        }
    ];
    $scope.mail_notification = 'all';
    $scope.message = "AngularJS select example";
});