forked from ArtemGnatenko/JavaScript-Lectures
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
500 lines (63 loc) · 1.98 KB
/
main.js
File metadata and controls
500 lines (63 loc) · 1.98 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
// Lesson_22 **************************
// AngularJS
(function (){
"use strict";
angular.module("app", [
"price"
]).run(function($templateCache) {
$templateCache.put('myTemplate.html', 'This is the<br/> content of the template');
})
}) ();
// (function (){
// "use strict";
// angular.module("price", [])
// .filter("price", price);
// function price(number, symbol) {
// return (symbol || "$") + number;
// }
// }) ();
(function (){
"use strict";
angular.module("price", [])
.filter("price", price);
function price() {
return function (number, symbol) {
return (symbol || "$") + number;
};
}
}) ();
(function() {
"use strict";
angular.module("app")
.controller("myCtrl", myCtrl);
myCtrl.$inject = ["$scope", "$filter", "$http", "$q", "$sce", "$templateCache"];
function myCtrl($scope, $filter, $http, $q) {
var myCtrl = this;
myCtrl.price = $filter("price")(25, "#");
myCtrl.serverData = {};
myCtrl.userAction = "";
myCterl.html = $sce.trustAsHtml("<h1>test text</h1>");
myCtrl.askUser = askUser;
$scope.$applyAsync(function() {
myCtrl.serverData = {"myKey1": "asdasd"};
})
console.log($scope);
$http
.get("http://www.mocky.io/v2/58d4161a100000db0cd7a6b5")
.then(function (data){
myCtrl.serverData = data.data;
});
function ascUser() {
myModal().then(function (userAnswer) {
myCtrl.userAction = userAnswer;
})
}
function myModal() {
var deffered = $q.defer();
setTimeout(function() {
deffered.resolve("User click OK");
}, 5000);
return deffered.promice;
}
}
})();