-
Notifications
You must be signed in to change notification settings - Fork 55
/
07-4-resolve.html
56 lines (54 loc) · 1.34 KB
/
07-4-resolve.html
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
<!DOCTYPE html>
<html>
<head>
<title>ng-view</title>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.0-beta.11/angular.min.js"></script>
<script src="https://code.angularjs.org/1.3.0-beta.11/angular-route.min.js"></script>
<script>
var app = angular.module('app', ['ngRoute']);
app.config(['$routeProvider', function($routeProvider){
$routeProvider.when('/',{
template:'<h3>This will never show up!</h3>',
controller:'BasicCtrl',
resolve:{
app:function($q){
var defer = $q.defer();
return defer.promise;
}
}
})
.when('/sup',{
template: '<h3>Sup World!</h3>',
controller:'BasicCtrl',
resolve:{
app:function($q){
var defer = $q.defer();
defer.resolve();
return defer.promise;
}
}
})
.when('/bye',{
template:'<h3>Appears after 3 seconds! bye!</h3>',
controller:'BasicCtrl',
resolve:{
app:function($q, $timeout){
var defer = $q.defer();
$timeout(function(){
defer.resolve()
}, 3000);
return defer.promise;
}
}
});
}]);
app.controller('BasicCtrl', function($scope){
$scope.dt = {title:'This application is very useful'};
});
</script>
</head>
<body ng-app='app'>
<a href="#">Home</a> | <a href="#/sup">Ask me whats up</a> | <a href="#/bye">Say bye</a><br />
<ng-view></ng-view>
</body>
</html>