-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathto-do-list.html
More file actions
152 lines (122 loc) · 3.07 KB
/
to-do-list.html
File metadata and controls
152 lines (122 loc) · 3.07 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
<!doctype html>
<html ng-app='project'>
<title>Angular to-do list demo page</title>
<style type='text/css'>
body{
font-family: arial;
color: #555;
}
li{
list-style: none outside none;
display: inline-block;
margin: 0 10px;
}
</style>
<head>
<script type='text/javascript' src='angular.js'></script>
<script type='text/javascript' src='angular-1.2.5/angular-resource.js'></script>
<script type='text/javascript' src='angular-1.2.5/angular-route.js'></script>
<script type='text/javascript'>
angular.module('project', ['ngRoute'])
.factory('List', function(){
var service = {
list: [
{name:'gee', age: 25},
{name:'yury', age:25}
]
};
return service;
})
.config(function($routeProvider){
$routeProvider
.when('/', {
controller: 'listController',
templateUrl: 'list.html'
})
.when('/detail/:name',{
controller: 'detailController',
templateUrl: 'detail.html'
})
.otherwise({
redirectTo: '/'
});
})
.controller('listController', function($scope, List){
console.log('list is');
console.log(List);
$scope.myname = 'gee';
$scope.age = '25';
//$scope.inputName = '';
$scope.list = List.list;
$scope.getCount = function(){
console.log('in getting count');
return this.list.length;
};
$scope.getName = function(){
console.log('in getting name');
return '123';
}
$scope.addPerson = function(){
console.log(this === $scope);
console.log($scope);
this.list.push({name: this.inputName, age: 25});
}
})
.controller('detailController', function($scope, $routeParams){
$scope.name = 'geegeegee';
console.log('detailController arguments');
console.log(arguments);
})
.controller('testController', function($scope, List, $routeParams){
console.log('argumetns');
console.log(arguments);
console.log('list is');
console.log(List);
$scope.name = 'test controller';
$scope.list = List.list;
$scope.getCount = function(){
return $scope.list.length;
}
});
</script>
<script type='text/javascript'>
function myController($scope){
$scope.myname = 'gee';
$scope.age = '25';
//$scope.inputName = '';
$scope.list = [
{name:'gee', age: 25},
{name:'yury', age:25}
]
$scope.getCount = function(){
console.log('in getting name');
return this.list.length;
}
$scope.addPerson = function(){
console.log(this === $scope);
console.log($scope);
this.list.push({name: this.inputName, age: 25});
}
}
</script>
</head>
<body>
<button ng-click='count = count+1' ng-init="count=0">click</button>
count is {{click}}
<!-- <div ng-view> -->
<div ng-controller='testController'>
text is {{name}}<br>
count is {{getCount()}}
<button ng-click="name=name+11">click</button>
</div>
</body>
<!-- <body ng-controller='myController'>
<p>There is <span>{{getCount()}}</span> people in the current list!<p>
<input type='text' ng-model='inputName'><button ng-click='addPerson()'>add</button>
hello {{inputName}}
<ul ng-repeat='person in list'>
<li>{{person.name}}</li>
<li>{{person.age}}</li>
</ul>
</body> -->
</html>