You can also use (focusout) event:
Use (eventName)
for while binding event to DOM, basically ()
is used for event binding. Also you can use ngModel
to get two way binding for your model
. With the help of ngModel
you can manipulate model
variable value inside your component
.
Do this in HTML file
<input type="text" [(ngModel)]="model" (focusout)="someMethodWithFocusOutEvent($event)">
And in your (component) .ts file
export class AppComponent {
model: any;
constructor(){ }
someMethodWithFocusOutEvent(){
console.log('Your method called');
// Do something here
}
}