aboutsummaryrefslogtreecommitdiffstats
path: root/framework/src/onos/web/gui/src/main/webapp/_sdh/ng-examples/ch05-01-need-for-service-app.js
blob: 4e25b0b173bf19273dcc8d9aab8d6acf4adc5c83 (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
// ch05-01-need-for-service-app.js

angular.module('notesApp', [])
    .controller('MainCtrl', [function () {
        var self = this;
        self.tab = 'first';
        self.open = function (tab) {
            self.tab = tab;
        }
    }])
    .controller('SubCtrl', [function () {
        var self = this;
        self.list = [
            {id: 0, label: 'Item 0'},
            {id: 1, label: 'Item 1'}
        ];

        self.add = function () {
            var n = self.list.length;
            self.list.push({
                id: n,
                label: 'Item ' + n
            });
        }
    }]);

/*
 NOTE: When we use controllers, they are instances that get created and
       destroyed as we navigate across the application. Any state they
        hold is temporary at best, and cannot be communicated to other
        controllers.

        That's why we'd use "services" instead.
 */