I want extend the default inputDirective in angular.so I wrote these code:
module.config(function($provide){
$provide.decorator('inputDirective',function($delegate){
var directive = $delegate[0];
var originalLink = directive.link;
directive.compile=function(ele,attr,transclude){
return function(scope,ele,attr,contr){
ele.on('click',function(){
scope.amount=888;
})
originalLink.apply(this,arguments);
return originalLink;
}
}
})
})
<form name='simpleForm'>
<input name='times' ng-model='times'/>
</form>
Since these code,I want result like that:The $scope.amount in my controller will be 888 when I click the input element. Now,It really worked,But the $scope.simpleForm and $scope.simpleForm.times still are pristine. The $dirty attributes still are false.
I'm so confused,Why like that?
I need help . Thank you everybody .