I am trying to implement an angular directive that will hide zero of field as soon as the is on DOM. basically this
Hide Value in input when it's zero in angular Js
my code look something like this :
<input hide-zero-onload ng-model="test"></input>
.directive('hideZeroOnload', function() {
return {
link: function(scope, element) {
element.on('input load', function() {
console.log('loaded');
if (this.value === '0') {
this.value = '-';
}
});
}
};
});
However,the console log is never printed. I also tried 'input onload', 'input init', 'input all', and 'input', with all the same result. I don't know what event keyword is emitted when the is first added to the DOM? or how can I find out? You can check the code out http://plnkr.co/edit/TwraJlxZSd3TeSYscExq?p=preview