1/* Two-Way Data Binding
2 - communicates data between the component and the view
3 (bi-directionally)
4 - this is acheived by using the ngModel directive
5 - include `import { FormsModule } from @angular/forms`
6 - syntax: `[(ngModel)]='some value'`
7*/
8
9import { Component } from '@angular/core';
10import { FormsModule } from '@angular/forms';
11
12@Component({
13 selector: 'app-example',
14 template: `
15 Enter the value: <input [(ngModel)]='val'>
16 <br>
17 Entered value is: {{val}}
18 `
19})
20
21export class AppComponent {
22 val: string = '';
23}
24
25/*
26Process:
27 1. View communicates inputted value to AppComponent
28 2. AppComponent communicates the updated val to the view
29 via {{val}}
30*/
31