-
Notifications
You must be signed in to change notification settings - Fork 0
/
appsec5.25-5.28.js
85 lines (51 loc) · 2.1 KB
/
appsec5.25-5.28.js
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
// MSSG - start: 8-31-2015 -- SPA
var myApp = angular.module('myApp', ['ngRoute']);
// The ngRoute stuff is included for sec 5.27
///////////////////////////////////////////// Sec 5.25
myApp.controller('mainController525', ['$scope', function($scope) {
$scope.name = 'Main';
}]);
myApp.controller('secondController525', ['$scope', function($scope) {
$scope.name = 'Second';
}]);
///////////////////////////////////////////// Sec 5.26
window.addEventListener('hashchange', function() {
if (window.location.hash === '#/bookmark/1') {
console.log('Page 1 is cool.');
}
if (window.location.hash === '#bmark2') {
console.log('Let me go get Page 2.');
}
if (window.location.hash === '#bmarkk3') {
console.log('Here\'s Page 3.');
}
});
///////////////////////////////////////////////// Sec 5.27
// Initial stuff using built-in route parsing angjs tools:
myApp.controller('mainController527', ['$scope', '$location', '$log', function($scope, $location, $log) {
// This will log the stuff after the hashmark to the console log area
$log.info($location.path())
}]);
// More complex stuff using the angular-route module:
myApp.config(function ($routeProvider) {
$routeProvider
// Watch for the hash mark
.when('/', {
templateUrl: 'pages/main.html',
controller: 'mainController527a'
})
// Watch for the 'second' URL
.when('/second', {
templateUrl: 'pages/second.html',
controller: 'secondController527b'
})
});
// We can use separate controllers for each webpage, as if they're totally separate domains
myApp.controller('mainController527a', ['$scope', '$log', function($scope, $log) {
// Assign dif vals into each controller's scope name
$scope.name = 'Mainjuice';
}]);
myApp.controller('secondController527b', ['$scope', '$log', function($scope, $log) {
// Assign dif vals into each controller's scope name
$scope.name = 'Secondstring';
}]);