-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy path4.2-broadcast.html
53 lines (43 loc) · 962 Bytes
/
4.2-broadcast.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
<!DOCTYPE html>
<html ng-app="plunker">
<head>
<meta charset="utf-8"/>
<title>AngularJS Plunker</title>
<link rel="stylesheet" href="style.css"/>
<script src="angular.js"></script>
</head>
<body ng-controller="MainCtrl">
<ul>
<li ng-repeat="item in arr track by $index">
<span>{{$id}}</span>
<ul>
<li ng-repeat="item in arr track by $index">
<span>{{$id}}</span>
<ul>
<li ng-repeat="item in arr track by $index">
<span ng-click="test()">{{$id}}</span>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</body>
<style>
.ng-scope {
border: solid 1px #0066cc;
margin: 5px;
}
</style>
<script>
var app = angular.module('plunker', []);
app.controller('MainCtrl', function ($scope, $rootScope) {
$scope.arr = [1, 2, 3];
$rootScope.$on('123', function() {
});
$scope.test = function() {
$scope.$broadcast('123');
};
});
</script>
</html>