继续浏览精彩内容
慕课网APP
程序员的梦工厂
打开
继续
感谢您的支持,我会继续努力的
赞赏金额会直接到老师账户
将二维码发送给自己后长按识别
微信支付
支付宝支付

ng-repeat = "i in [4]" [4]一个包含一个4的数组

果酒柠檬子
关注TA
已关注
手记 1
粉丝 0
获赞 0

html```
<div ng-controller="EventController">
Root scope    
<tt>MyEvent</tt>count:{{count}}
<ul>
<li ng-repeat = "i in [2,1]" ng-controller = "EventController">
<button ng-click="$emit('MyEvent')">
$emit('MyEvent')
</button>
<button ng-click="$broadcast('MyEvent')">
$broadcast('MyEvent')
</button>
<br>
Middle scope   
<tt>MyEvent</tt>count:{{count}}
<ul>
<li ng-repeat="item in [1,3]" ng-controller="EventController">
Leaf scope   
<tt>MyEvent</tt>count:{{count}}
</li>
</ul>
</li>
</ul>
</div>

js:
function EventController($scope) {
    $scope.count = 0;
    $scope.$on("MyEvent",function(){
        $scope.count++;
    })
}

输入代码

打开App,阅读手记
0人推荐
发表评论
随时随地看视频慕课网APP