form.FormController.$addControl()

$addControl(control);

Register a control with the form. Input elements using ngModelController do this automatically when they are linked.

Note that the current state of the control will not be reflected on the new parent form. This is not an issue with normal use, as freshly compiled and linked controls are in a $pristine state.

However, if the method is used programmatically, for example by adding dynamically created controls, or controls that have been previously removed without destroying their corresponding DOM element, it's the developers responsibility to make sure the current state propagates to the parent form.

For example, if an input control is added that is already $dirty and has $error properties, calling $setDirty() and $validate() afterwards will propagate the state to the parent form.

Parameters

Param Type Details
control object

control object, either a form.FormController or an ngModel.NgModelController

doc_AngularJS
2016-03-29 16:11:06
Comments
Leave a Comment

Please login to continue.