aboutsummaryrefslogtreecommitdiffstats
path: root/framework/src/onos/web/gui/src/main/webapp/_sdh/ng-examples/ch04-11-select-example.html
blob: a8cda33c6648f2b4485c2705c28c7cfa2873e29b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<!DOCTYPE html>
<html ng-app="notesApp">
<head>
    <title>Notes App</title>
    <script src="../../tp/angular.js"></script>
</head>
<body ng-controller="MainCtrl as ctrl">

    <div>
        <select ng-model="ctrl.selectedCountryId"
                ng-options="c.id as c.label for c in ctrl.countries">
        </select>
        Selected Country ID: {{ctrl.selectedCountryId}}
    </div>

    <div>
        <select ng-model="ctrl.selectedCountry"
                ng-options="c.label for c in ctrl.countries track by c.id">
        </select>
        Selected Country: {{ctrl.selectedCountry}}
    </div>

    <script type="text/javascript">
        angular.module('notesApp', [])
                .controller('MainCtrl', [function () {
                    var self = this;

                    self.countries = [
                        {label: 'UK', id: 1},
                        {label: 'USA', id: 2},
                        {label: 'France', id: 3},
                        {label: 'Italy', id: 4}
                    ];
                    var first = self.countries[0];
                    self.selectedCountryId = first.id;
                    self.selectedCountry = first;
                }]);
    </script>

</body>
</html>