相关疑难解决方法(0)

angularjs将属性中新创建的数组传递给指令

我创造了这个小提琴来展示我的问题......

http://jsfiddle.net/dQDtw/

我正在将一个新创建的数组传递给一个指令,一切正常.但是,我在控制台窗口中收到错误,指出:

Error: [$rootScope:infdig] 10 $digest() iterations reached. Aborting!

有什么想法我需要按摩来清理它吗?我希望能够重用该指令而无需更新控制器.

这是html

<body ng-app="myApp">
    <test-dir fam-people='[1,4,6]'> </test-dir>
    <test-dir fam-people='[2,1,0]'> </test-dir>
</body>
Run Code Online (Sandbox Code Playgroud)

这是JS.

var myApp = angular.module('myApp',[]);

myApp.directive('testDir', function() {
            return { restrict: 'E'
                   , scope: { famPeople: '=famPeople' }
                   , template: "<ol> <li ng-repeat='p in famPeople'> {{p}}"
                   };
    });
Run Code Online (Sandbox Code Playgroud)

angularjs angularjs-directive

11
推荐指数
2
解决办法
2万
查看次数

标签 统计

angularjs ×1

angularjs-directive ×1