2 way binding in angular code example
Example 1: Bidirectionnal model binding
content_copy
<app-sizer [(size)]="fontSizePx"></app-sizer>
Example 2: property binding angular documentation
// component.ts
@Component({
templateUrl: 'component.html',
selector: 'app-component',
})
export class Component {
name = 'Peter';
updateName() {
this.name = 'John';
}
}
// component.html
<p>My name is {{name}}</p>
<button (click)="updateName()">Update button</button>