I have this attribute directive which under specific conditions needs to add an attribute. But thats not all, I also want to bind the value of this attribute to a property on the $scope
. In code (simplified) this looks like
...
.directive('do-magic', function ($timeout) {
restrict: 'A',
link: function (scope, element) {
scope.isMagicDone = false;
element.attr('is-magic-done', scope.isMagicDone);
$timeout(function () {
scope.isMagicDone = true;
});
}
});
So, after the $timeout
executes I need the is-magic-done
value to be true
. So the question is: How can I setup a binding programmatically ?