Posts

Showing posts with the label angular form

Create Reactive form in angular

Image
  In angular we can create two types of forms 1. Reactive form 2.template based form In Reactive form  : all the codes handle in type script , no need to use ngModel to get and set value in control. we define form and formcontrolname for each control , and through formControl we get and set value .reactive form code is neat and clean when we have more complex structure or validation we should use reactive form . Template driven  : data binding is done via ngModel ,generally we can use this approach for simple form ,in this approach code became messy and very difficult to manage . Also in this approach difficult to handle all validation ,need more coding. So , I like to go with Reactive form approach instead of Template based. In our tutorial all forms will be reactive , but we can use both approach if required. I am going to create employee form which will have below fields : Employee Id ,Employee Name, email Id,Mobile Number,Password etc.. our final output will be a...