aboutsummaryrefslogtreecommitdiffstats
path: root/framework/src/onos/web/gui/src/main/webapp/_sdh/ng-examples/ch04-09-checkbox-example.html
blob: fe35af1077a023aaf891d9b550c29fae7ce9f14e (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
42
43
44
45
46
47
<!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>
        <h2>What are your favorite sports?</h2>
        <div ng-repeat="sport in ctrl.sports">
            <label ng-bind="sport.label"></label>
            <div>
                With binding:
                <input type="checkbox"
                       ng-model="sport.selected"
                       ng-true-value="'YES'"
                       ng-false-value="'NO'"/>
            </div>
            <div>
                using ng-checked:
                <input type="checkbox"
                       ng-checked="sport.selected === 'YES'"/>
            </div>
            <div>
                Current state: {{sport.selected}}
            </div>
            <br/>
        </div>

    </div>

    <script type="text/javascript">
        angular.module('notesApp', [])
                .controller('MainCtrl', [function () {
                    var self = this;
                    self.sports = [
                        {label: 'Basketball', selected: 'YES'},
                        {label: 'Cricket', selected: 'NO'},
                        {label: 'Soccer', selected: 'NO'},
                        {label: 'Swimming', selected: 'YES'}
                    ];
                }]);
    </script>

</body>
</html>