Reputation: 32788
This is related to a question I asked earlier.
link: function (scope, element, attrs, ngModel) {
$wmdInput.on('keyup', _.debounce(function () {
rawContent = $wmdInput.val(); // LINE 1
scope.$apply(function () {
ngModel.$setViewValue(rawContent); // LINE 2
});
}, 500));
Inside the link portion of a directive. Is it necessary to set the model value inside a
scope.$apply( function ()
?
Upvotes: 0
Views: 1451
Reputation: 77904
I think that in your case you need invoke $apply
. $scope.$apply()
calls $scope.$digest()
. The $digest
loops through all watchers on the specific scope
From DOCS:
Note that calling
$setViewValue(value)
function does not trigger a $digest.
Upvotes: 2