Sunday, 3 November 2019

What is two-way data binding in angular?


Two-way data binding: One of powerful feature of angular is two-way data binding where both view template and component class get effected when some changes occurred. See the below example




The above code will not work as it is using [(ngModel)] because this is not available and not known to the angular. To work this, we need to add FormsModule references into AppModule.ts file.

Here are the steps to import FormsModule into AppModule

1. Open 
app.module.ts file
2. Include the following import statement in it
    
import { FormsModule } from '@angular/forms';
3. Also, include FormsModule in the 'imports' array of @NgModule
    imports  [
BrowserModuleFormsModule]

No comments:

Post a Comment