Skip to content Skip to sidebar Skip to footer

Updating A {{ Variable }} In My Directive Template

I don't think I am understanding how to set a {{ variable }} in my directive template correctly. The only way I can manage to update it is by calling $scope.$apply() and all I am t

Solution 1:

You do need to use $apply() for events that change the scope that are outside of angular core in order to let angular know to run a view digest

For events managed by core directives such as ng-click , $apply() is called internally.

Your DOM listeners are not within such a directive. You can also use $timeout to avoid collisions with digest in progress errors occurring.

$timeout will defer calling $apply itself internally if digests are in progress

Post a Comment for "Updating A {{ Variable }} In My Directive Template"