ngmodel two way binding code example
Example 1: what is ngmodel property binding
<input [(ngModel)]="username">
<p>Hello {{username}}!</p>
Example 2: Bidirectionnal model binding
content_copy
<app-sizer [(size)]="fontSizePx"></app-sizer>
Example 3: angular two way property binding
import { Component } from '@angular/core';
import { FormsModule } from '@angular/forms';
@Component({
selector: 'app-example',
template: `
Enter the value: <input [(ngModel)]='val'>
<br>
Entered value is: {{val}}
`
})
export class AppComponent {
val: string = '';
}