This repo gives you a boiler plate start for using Angular forms, both Template driven and Reactive forms.
Directions to use:
- Clone or download this repo.
- If you downloaded the repo, extract the files and save it to your prefferd location.
- Navigate to the project location using your command line.
- Run "npm install". This installs all the dependencies listed on package.json file.
- Once the dependencies are installed, run "ng serve". This command starts a local server on port 4200.
- Open your browser and got to "localhost:4200". You can see two forms, one on top is the teplate driven approach and one at the bottom is the Reactive approach.
Template driven:
- This approach is close to the earlier version of angular.
- This approach uses two-way databinding using ngModel.
- Less flexibility on adding new fields to the form.
- Cannot customize validations.
Reactive approach:
- This approach is new in Angular 2 and further versions.
- It gives flexibility of adding custom validations.
- Less lines of HTML content compoared to template driven.
- Form is built in typescript file and then synced with HTML.
- Easy for grouping of form elements.
Please email me at narvaneni.rakesh2012@gmail.com for furhter questions.