In Angular 2.0, model driven form using Form Builder, I have,
ngOnInit() {
this.user = this.fb.group({
id: ['', [Validators.required, Validators.minLength(2)]],
name: ['', [Validators.required, Validators.minLength(5)]]
});
this.user.get('id').valueChanges.subscribe(value => {
alert("Change detected);
});
}
and in HTML I have :
<input type="text" formControlName="id" >
But what happening is for every letter I change in text box the alert("Change detected"); is getting fired, instead after tabout only I need to call alert("Change detected"). I know in Angular 1.x to achieve this by using ng-model-options but how to achieve the same in Angular 2.0?