I have created a custom directive that takes some scope parameters. I used a watchGroup for incoming parameters change. This is part of the directive:
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;
}
});
I am using the directive as follows in my page:
<scripting repairer="repairer" request="getRequest(repairer,initial)" initial="initial" />
UPDATE: after playing around a bit more I think the issue is with the getRequest method and not the watchGroup statement.
Why am I getting this error now:
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>>"}]]
Here is a plunker ref: http://plnkr.co/edit/dSkjP1Vkvwd4fVauiFqa?p=preview