【发布时间】:2016-02-29 19:59:02
【问题描述】:
我创建了一个带有一些范围参数的自定义指令。我使用 watchGroup 来更改传入参数。这是指令的一部分:
scope.$watchGroup(['repairer', 'initial'], function() {
if (scope.initial) {
scope.Repairer = scope.initial;
} else {
scope.Repairer = scope.repairer;
}
console.log('scope.Repairer value:', scope.Repairer);
if (scope.Repairer) {
console.log('wooohoo calling scriptservice');
scriptingService.getScript(scope.request).then(function(scripts) {
scope.scripts = scripts;
});
} else {
scope.scripts = null;
}
});
我在我的页面中使用如下指令:
<scripting repairer="repairer" request="getRequest(repairer,initial)" initial="initial" />
更新:在玩了一会儿之后,我认为问题在于 getRequest 方法而不是 watchGroup 语句。
为什么我现在收到此错误:
Error: [$rootScope:infdig] 10 $digest() iterations reached. Aborting!
Watchers fired in the last 5 iterations: [[{"msg":"fn: regularInterceptedExpression","newVal":{"allocationProcess":"direct","allocationSource":"internal","brand":"popie","includeSegment":false,"relationship":"lol","ruralSearch":true,"state":"VIC"},"oldVal":{"allocationProcess":"direct","allocationSource":"internal","brand":"popie","includeSegment":false,"relationship":"lol","ruralSearch":true,"state":"VIC"}}],[{"msg":"fn: regularInterceptedExpression","newVal":{"allocationProcess":"direct","allocationSource":"internal","brand":"popie","includeSegment":false,"relationship":"lol","ruralSearch":true,"state":"VIC"},"oldVal":"<<already seen>>"}],[{"msg":"fn: regularInterceptedExpression","newVal":{"allocationProcess":"direct","allocationSource":"internal","brand":"popie","includeSegment":false,"relationship":"lol","ruralSearch":true,"state":"VIC"},"oldVal":"<<already seen>>"}],[{"msg":"fn: regularInterceptedExpression","newVal":{"allocationProcess":"direct","allocationSource":"internal","brand":"popie","includeSegment":false,"relationship":"lol","ruralSearch":true,"state":"VIC"},"oldVal":"<<already seen>>"}],[{"msg":"fn: regularInterceptedExpression","newVal":{"allocationProcess":"direct","allocationSource":"internal","brand":"popie","includeSegment":false,"relationship":"lol","ruralSearch":true,"state":"VIC"},"oldVal":"<<already seen>>"}]]
这是一个 plunker 参考:http://plnkr.co/edit/dSkjP1Vkvwd4fVauiFqa?p=preview
【问题讨论】:
标签: angularjs angularjs-directive