-
Notifications
You must be signed in to change notification settings - Fork 0
/
scope.html
47 lines (41 loc) · 1.01 KB
/
scope.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
<!DOCTYPE html>
<html >
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>Document</title>
<script type="text/javascript" src="./js/angular.js"></script>
</head>
<body ng-app="myapp">
<!-- 控制器嵌套,作用域受影响 -->
<h3 ng-controller="firstController">
{{name}}
{{age}}
<h4 ng-controller="threeController">
{{name}}
{{age}}
</h4>
</h3>
<h4 ng-controller="threeController">
{{name}}
{{age}}
</h4>
<h3 ng-controller="secondController">
{{name}}{{age}}
</h3>
</body>
<script type="text/javascript">
var module = angular.module("myapp",[]);
module.controller("firstController",function($scope,$rootScope){
//$rootScope.age =29;
$scope.name="firstController";
})
module.controller("threeController",function($scope,$rootScope){
$rootScope.age =30;
//$scope.name="threeController";
})
module.controller("secondController",function($scope,$rootScope){
$scope.name="secondController";
$rootScope.age =29;
})
</script>
</html>