Skip to content

rakeshnarvaneni1993/Angular-Forms

Repository files navigation

This repo gives you a boiler plate start for using Angular forms, both Template driven and Reactive forms.

Directions to use:

  1. Clone or download this repo.
  2. If you downloaded the repo, extract the files and save it to your prefferd location.
  3. Navigate to the project location using your command line.
  4. Run "npm install". This installs all the dependencies listed on package.json file.
  5. Once the dependencies are installed, run "ng serve". This command starts a local server on port 4200.
  6. 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:

  1. This approach is close to the earlier version of angular.
  2. This approach uses two-way databinding using ngModel.
  3. Less flexibility on adding new fields to the form.
  4. Cannot customize validations.

Reactive approach:

  1. This approach is new in Angular 2 and further versions.
  2. It gives flexibility of adding custom validations.
  3. Less lines of HTML content compoared to template driven.
  4. Form is built in typescript file and then synced with HTML.
  5. Easy for grouping of form elements.

Please email me at narvaneni.rakesh2012@gmail.com for furhter questions.