javascript / beginner
Snippet
Two-Way Data Binding with ngModel
Two-way data binding allows data to flow from the component to the view and from the view back to the component automatically. It uses the 'banana-in-a-box' syntax [()].
snippet.js
1
2
<input [(ngModel)]="userName"><p>Hello, {{ userName }}!</p>
angular
Breakdown
1
[(ngModel)]="userName"
Binds the input value to the 'userName' variable in the component class bidirectionally.