-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patht1.html
More file actions
90 lines (74 loc) · 2.11 KB
/
Copy patht1.html
File metadata and controls
90 lines (74 loc) · 2.11 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
<!DOCTYPE html>
<html>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular-sanitize.js"></script>
<body ng-app="myApp">
<div ng-controller="myCtrl">
<h1>The $location Service</h1>
<p>The url of this page is:</p>
<h3>Url: {{myUrl}}</h3>
<h3>Hash: {{myUrl_hash}}</h3>
</div>
<p>This example uses the built-in $location service to get the absolute url of the page.</p>
<hr>
<div ng-controller="myhttp">
<h1>The $http Service</h1>
<p>{{myWelcomeinHTML}}</p>
<p ng-bind-html="myWelcomeinHTML"></p>
<p>{{myWelcomeinPHP}}</p>
<ul>
<li ng-repeat="x in names">{{x.name+' - '+x.gender}}</li>
</ul>
</div>
<hr>
<div ng-controller="mytimeout">
<h1>The $timeout Service</h1>
<h2>{{myHeader}}</h2>
</div>
<hr>
<div ng-controller="myinterval">
<h1>The $interval Service</h1>
<p>The time is:</p>
<h2>{{theTime}}</h2>
<h3>Lucky num for this momment: {{ranNum}}</h3>
</div>
<script>
var app = angular.module('myApp', ['ngSanitize']);
app.controller('myCtrl', function($scope,$location) {
$scope.myUrl = $location.absUrl();
$scope.myUrl_hash = $location.$$hash;
purl=$location;
console.log(purl);
});
app.controller('myhttp',function($scope,$http) {
$http.get("welcome.html").then(function (response) {
$scope.myWelcomeinHTML = response.data;
});
$http.get("welcome.php").then(function (response) {
$scope.myWelcomeinPHP = response.data;
});
//get a json
$http.get("json.php").then(function (response) {
$scope.names=response.data;
});
});
app.controller('mytimeout',function($scope,$timeout) {
$scope.myHeader = "Hello World! (will disappear after 3000ms)";
$timeout(function () {
$scope.myHeader = "How are you today?";
}, 3000);
});
app.controller('myinterval',function($scope,$interval) {
$scope.theTime = new Date().toLocaleTimeString();
//random integer form 0 to 9
$scope.ranNum=Math.floor(Math.random() * 10);
$interval(function () {
$scope.theTime = new Date().toLocaleTimeString();
}, 1000);
$interval(function () {
$scope.ranNum=Math.floor(Math.random() * 10);
}, 2000);
});
</script>
</body>
</html>