Seeking guidance on utilizing an AngularJS directive as an HTML element, with the intention to provide it two values. One will be fetched by iterating through a collection, while the other will be derived from that value:
<mydirective myval="val" mymagic="getMagic(val)" ng-repeat="val in values" />
Everything functions correctly when the getMagic(val)
function consistently returns the same result. However, since the values are Arrays that change with each call, it leads to an
[$rootScope:infdig] 10 $digest() iterations reached. Aborting!
error. Click here to view a fiddle of my scenario (it works if the function is defined like it is in the commented line).
Is there a method to prevent reevaluation or "watching" of the mymagic parameter? The goal is for the value to update only when the values collection changes, without calling the function unnecessarily.
How can I achieve this?