(element, attrs, $scope, $animate, $interpolate)
| 18135 | //asks for $scope to fool the BC controller module |
| 18136 | FormController.$inject = ['$element', '$attrs', '$scope', '$animate', '$interpolate']; |
| 18137 | function FormController(element, attrs, $scope, $animate, $interpolate) { |
| 18138 | var form = this, |
| 18139 | controls = []; |
| 18140 | |
| 18141 | var parentForm = form.$$parentForm = element.parent().controller('form') || nullFormCtrl; |
| 18142 | |
| 18143 | // init state |
| 18144 | form.$error = {}; |
| 18145 | form.$$success = {}; |
| 18146 | form.$pending = undefined; |
| 18147 | form.$name = $interpolate(attrs.name || attrs.ngForm || '')($scope); |
| 18148 | form.$dirty = false; |
| 18149 | form.$pristine = true; |
| 18150 | form.$valid = true; |
| 18151 | form.$invalid = false; |
| 18152 | form.$submitted = false; |
| 18153 | |
| 18154 | parentForm.$addControl(form); |
| 18155 | |
| 18156 | /** |
| 18157 | * @ngdoc method |
| 18158 | * @name form.FormController#$rollbackViewValue |
| 18159 | * |
| 18160 | * @description |
| 18161 | * Rollback all form controls pending updates to the `$modelValue`. |
| 18162 | * |
| 18163 | * Updates may be pending by a debounced event or because the input is waiting for a some future |
| 18164 | * event defined in `ng-model-options`. This method is typically needed by the reset button of |
| 18165 | * a form that uses `ng-model-options` to pend updates. |
| 18166 | */ |
| 18167 | form.$rollbackViewValue = function() { |
| 18168 | forEach(controls, function(control) { |
| 18169 | control.$rollbackViewValue(); |
| 18170 | }); |
| 18171 | }; |
| 18172 | |
| 18173 | /** |
| 18174 | * @ngdoc method |
| 18175 | * @name form.FormController#$commitViewValue |
| 18176 | * |
| 18177 | * @description |
| 18178 | * Commit all form controls pending updates to the `$modelValue`. |
| 18179 | * |
| 18180 | * Updates may be pending by a debounced event or because the input is waiting for a some future |
| 18181 | * event defined in `ng-model-options`. This method is rarely needed as `NgModelController` |
| 18182 | * usually handles calling this in response to input events. |
| 18183 | */ |
| 18184 | form.$commitViewValue = function() { |
| 18185 | forEach(controls, function(control) { |
| 18186 | control.$commitViewValue(); |
| 18187 | }); |
| 18188 | }; |
| 18189 | |
| 18190 | /** |
| 18191 | * @ngdoc method |
| 18192 | * @name form.FormController#$addControl |
| 18193 | * |
| 18194 | * @description |
nothing calls this directly
no test coverage detected