Reactive forms are built on the following base classes of the Form Model.
Form Group: route the similar value and status for collection of form control.
Form Control: route the value and validation status of individual form control.
Form Array: route the same value and status for an array of form control.
With reactive from, you mention the form model directly in the component class.
There are three steps to using form controls.
Enter the reactive forms module in your application. This module is communicating the reactive-form directives that you need to use reactive forms.
Generate a new Form Control sample and save it in the component.
Lodge the form control in the template.
Import { Reactive FormsModule } from ‘@angular/forms’
@NgModule({ imports: [ ReactiveFormsModule ] , } ) then, export class AppModule{}
ng generate component forms (component name)
Forms.component.ts
Import { Reactive FormsModule } from ‘@angular/forms’
And, inside the export class add
name = new formcontrol(‘’);
In forms.component.html
Inside the form you mention:
<Label>Name</label>
<input type=”text” [form Control] =”name>
This is the concept of Reactive forms in Angular. If you are interested to learn more details then you go through our website o7services.com. We are providing an Angular online/offline course in Jalandhar. We are also providing angular training in Jalandhar.
Leave a Reply