Transcordia LLC
Presentation Example Project
https://github.com/Transcordia/ng-meetup
The source for this presentation is in the "ng-directives" directory
<!--
The form directive is created. It is bound to the directive controller FormController
which is injected into its link function. The FormController initializes validation
and pristine state. Finally, myForm--a reference to the FormController--is added
to the scope.
-->
<form role="form" name="myForm" novalidate="novalidate">
<!--
Two directives are created: input directive and ngModel directive. The ngModel
directive requires as an optional controller, the FormController created above,
as well as an NgModelController, both of which are injected into its
link function as an array. The ngModelController is added to the myForm controller
as an attribute named "firstLastName"
-->
<input type="text" ng-model="user.firstLastName" name="firstLastName"
placeholder="Enter Name">
</form>
// The ngModelController.$error object holds a map each validation on the HTML Element
userForm.age.$error = {
required: false,
min: false,
max: true
}
// The FormController.$error object holds an map of validations, each holding
// the array of ngModelController objects
userForm.$error = {
max: [
// array containing each ngController Object that violates the "max" validation
],
required: [
// array each ngController Object that violates the "required" validation
]
}
ngModel.$validators.minDate = function (modelValue, viewValue)...