How does AngularJS handle form validation?
Instruction: Describe the mechanisms AngularJS provides for validating user input in forms.
Context: This question tests the candidate's experience with building robust, user-friendly forms using AngularJS's built-in validation features.
Updated
Official answer available
Read the opening below, then unlock the full answer and practical guidance.
AngularJS form and ngModel controllers track validity and interaction state. Built-in constraints include required, length, pattern and input-type rules. States such as $dirty and $touched describe interaction; they are not the same as $invalid. Asynchronous validation can also leave a control/form in $pending.
The following complete template fragment belongs inside a bootstrapped AngularJS application with vm.code available:...