DEMO
Why in the following example $render
is not called when the button is clicked?
The input
directive is running after your directive and thus it's $render
function is replacing yours.
Set your directive's priority to something greater than 0. For instance:
.directive("phoneNumber", function() {
return {
restrict: 'A',
require: 'ngModel',
priority: 1,
link: function(scope, element, attrs, ngModel) {
ngModel.$render = function() {
alert('rendering');
};
}
};
});
And your $render
will take precedence and you'll see your alert is called.