Validating AngularJS forms

In this section we explain how to use validation directives and how they work with ngFormController to provide a full validation framework.

Understanding ngFormController

Each form (or ngForm) directive creates an instance of ngFormController. The ngFormController object manages whether the form is valid or invalid and whether it is pristine or dirty. Importantly, it works with ngModelController to track each ngModel field within the form.

When an ngModelController is created, it registers itself with the first ngFormController it comes across as it traverses up its list of parent elements. This way, the ngFormController knows what input directives it should track. It can check whether these fields are valid/invalid or ...

Get Mastering Web Application Development with AngularJS now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.