forked from Ctrl-Alt-Delicious/CacheSimulator
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
46 lines (43 loc) · 1.51 KB
/
Copy pathapp.js
File metadata and controls
46 lines (43 loc) · 1.51 KB
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
angular.module('Simulator', ['ngMaterial', 'md.data.table'])
.config(function($mdThemingProvider) {
$mdThemingProvider.theme('docs-dark')
.primaryPalette('blue')
.accentPalette('blue-grey')
.dark();
}).controller('IndexController', ['$scope', function($scope) {
var ctrl = this;
$scope.navs = [{
buttonTitle: "Overview",
active: true
},
{
buttonTitle: "L1",
active: true
}
];
$scope.changeView = function(index) {
for (var i = 0; i < $scope.navs.length; i++) {
if (index === i) {
$scope.navs[i].active = true;
//Broadcast sends an event to child controllers/components
$scope.$broadcast('updatedCaches', $scope.navs[i])
} else {
$scope.navs[i].active = false
}
}
//Pass the updated cache list to cacheDetail template to change its model
};
//Listens for an event emitted from a child controller/component
$scope.$on('updatedCacheList', function(event, data) {
$scope.navs = [{
buttonTitle: "Overview",
active: true
}];
var i = 1;
for (cache of data) {
$scope.navs[i++] = {
buttonTitle: cache.title
}
}
});
}]);