I am a newbie in angular 2 here. Just want to ask if how can I bind the [ngFormControl] value inside a directive? I tried using@HostBinding('value') get value {return this.el.value} but it just updates the nativeElement's value, not the [ngFormControl]'s value.
I am creating a number only directive wherein it accepts a configuration on what type of number to accept (e.g negative or positive, with or without decimal). If negative is allowed, I will allow the dash symbol (-) to be inputted. But when the user only inputs a dash and no tailing numbers, once the input loses its focus (blur event fires), I updated the nativeElement's value with empty string. The view is blank but the [ngFormControl] still has the value of '-'.
Here is my code for blur event:
@HostListener('blur', ['$event']) onBlur($event){
if(isNaN(this.el.value)){
this.el.value = '';
}
}
What I want to accomplish is for the directive to edit or modify or update the value of the [ngFormControl] from where the directive is attached to.
Thank you! =)