Posts

Showing posts with the label form angular 6

Reactive forms in Angular 6

Image
Reactive forms in Angular 6 Reactive forms also powerful forms and provide a straightforward path to testing because you are assured that your data is consistent and predictable when requested. Any consumers of the streams have access to manipulate that data safely, How to work reactive forms in angular 6. Step 1: The reactive forms module - import ReactiveFormsModule from the @angular/forms package and add appmodule.ts file.  src/app/app.module.ts (excerpt)-  import { ReactiveFormsModule } from '@angular/forms'; @NgModule({   imports: [     // other imports ...     ReactiveFormsModule   ], }) export class AppModule { } Step 2:  Generate a component for the control  -  ng generate component form The FormControl class is the basic building block when using reactive forms. To register a single form control, import the FormControl class into your component and create a new instance of the form control ...