-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathappsec4.17-4.24.js
More file actions
174 lines (98 loc) · 4.5 KB
/
appsec4.17-4.24.js
File metadata and controls
174 lines (98 loc) · 4.5 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
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
// MSSG - start: 7-28-2015 - Learning about injection
var myApp = angular.module('myApp', []);
///////////////////////////////////////////// 4.17
myApp.controller('mainController417', ['$scope', '$timeout', function($scope, $timeout) {
$scope.name = 'MSSG';
$timeout(function() {
$scope.name = 'Jessi + Kurt ';
}, 1000);
$timeout(function() {
$scope.name = 'Everybody rockin in the house tonite';
}, 2000);
}]);
///////////////////////////////////////////// 4.18 (and 4.19)
myApp.controller('mainController418', ['$scope', '$filter', function($scope, $filter) {
$scope.handle = ''; // This is a 2-way bound variable
$scope.lowercasehandle418 = function() { // This is a *function*
return $filter('lowercase')($scope.handle);
};
$scope.uppercasehandle418 = function() { // This is a *function*
return $filter('uppercase')($scope.handle);
};
}]);
///////////////////////////////////////////// 4.20
myApp.controller('mainController420', ['$scope', '$filter', '$timeout', function($scope, $filter, $timeout) {
// This is a 2-way bound variable
$scope.handle420 = '';
// This is a *function*
$scope.lowercasehandle420 = function() {
return $filter('lowercase')($scope.handle420);
};
$scope.uppercasehandle420 = function() { // This is a *function*
return $filter('uppercase')($scope.handle420);
};
// This is the watcher, to see if any keys are pressed or anything like this
$scope.$watch('handle420', function(newValue, oldValue) {
console.info('Changed!');
console.log('Old content of handle:' + oldValue);
console.log('New content of handle:' + newValue);
});
// After 1000 ms, display -- this is a service that takes the place of the setTimeout function of JS
$timeout(function() {
$scope.handle420 = 'HeresTheNewTwitterhandle';
console.log('******** From Sec 4.20 -- I am *telling* you: Scope changed!');
}, 1000);
}]);
///////////////////////////////////////////// 4.21
myApp.controller('mainController421', ['$scope', '$filter', function($scope, $filter) {
$scope.handle421 = '';
$scope.lowercasehandle421 = function() {
return $filter('lowercase')($scope.handle421);
};
$scope.char_reqt = 5;
$scope.rulesforlife = [
{ rulename: "Must be 5 characters" },
{ rulename: "Must not be used elsewhere" },
{ rulename: "Must be waaaay cool" }
];
console.log($scope.rules);
}]);
///////////////////////////////////////////// 4.22
myApp.controller('mainController422', ['$scope', function($scope) {
$scope.didyouclick= function(){
alert("You DID click me, you strapping young person, you");
};
$scope.nametoshow = 'MG is da man';
}]);
///////////////////////////////////////////// 4.23
myApp.controller('mainController423', ['$scope', '$filter', function($scope, $filter) {
///////////////////////// This section is *very* complex, and though i looked at it, didn't get the syntax very well, as he says will be likely -- it's mostly set up for sec 4.24
}]);
///////////////////////////////////////////// 4.24
myApp.controller('mainController', ['$scope', '$filter', '$http', function ($scope, $filter, $http) {
///////////////////////// This section is clearer, but still complex, and there's not much interactivity because i don't have a local DB or api, and can't run it. Watched, but skipped.
$scope.handle = '';
$scope.lowercasehandle = function () {
return $filter('lowercase')($scope.handle);
};
$scope.characters = 5;
$http.get('/api')
.success(function (result) {
$scope.rules = result;
})
.error(function (data, status) {
console.log(data);
});
$scope.newRule = '';
$scope.addRule = function () {
$http.post('/api', { newRule: $scope.newRule })
.success(function (result) {
console.log(result);
$scope.rules = result;
$scope.newRule = '';
})
.error(function (data, status) {
console.log(data);
});
};
}]);