Skip to content

Commit a560ac6

Browse files
committed
路由例子
1 parent d7916d8 commit a560ac6

File tree

1 file changed

+43
-3
lines changed

1 file changed

+43
-3
lines changed

view/route2.html

Lines changed: 43 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,57 @@
55
<meta charset="UTF-8">
66
<title></title>
77
</head>
8+
<script type="text/javascript" src="../js/angular.js"></script>
89

910
<body ng-app="angularRouteDemo">
1011
<section ng-controller="homeCtrl">
1112
<p>{{test}}</p>
13+
<p>{{name}}</p>
14+
<input ng-model="name" />
15+
<button ng-click="submit()">提交</button>
1216
</section>
17+
<!--<section ng-controller="addCtrl">
18+
19+
</section>-->
1320
</body>
1421
<script>
1522
var app = angular.module('angularRouteDemo', []);
16-
app.controller('homeCtrl', ['$scope', '$http', function($scope, $http) {
17-
$scope.test = "123";
18-
}])
23+
app.controller('homeCtrl', ['$scope', '$http', '$interval', 'intance', function($scope, $http, $interval, intance) {
24+
$scope.test = "123";
25+
$scope.name = '1';
26+
console.log(intance);
27+
// window.setInterval(function(){
28+
// $scope.name = 2;
29+
// },1000);
30+
// $interval(function() {
31+
// console.log("1");
32+
// }, 1000)
33+
console.log(intance.name)
34+
console.log(intance.addFunc(1,2));
35+
36+
$scope.submit = function() {
37+
$http.get('http://1.wsscatapi.applinzi.com/?format=' + $scope.name).success(function(e) {
38+
console.log(e);
39+
$scope.name = e;
40+
})
41+
}
42+
}])
43+
// app.controller('addCtrl',['$scope', '$http', 'intance', function($scope, $http, intance){
44+
// console.log(intance);
45+
// }])
46+
// app.factory('intance',function(){
47+
// return {};
48+
// })
49+
app.service('intance',[function(){
50+
var obj = {};
51+
obj.addFunc = function(a,b){
52+
return a+b;
53+
}
54+
//obj.name = 'yao';
55+
obj['name'] = 'yao';
56+
return obj;
57+
//console.log("这是我的服务");
58+
}])
1959
</script>
2060

2161
</html>

0 commit comments

Comments
 (0)