I am trying to implement an angular directive that will hide zero of field as soon as the <input>
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 <input>
is first added to the DOM? How can I find out?
You can check the code out http://plnkr.co/edit/TwraJlxZSd3TeSYscExq?p=preview