MCPcopy
hub / github.com/angular-ui/ui-router / FormController

Function FormController

test/angular/1.3/angular.js:18446–18667  ·  view source on GitHub ↗
(element, attrs, $scope, $animate, $interpolate)

Source from the content-addressed store, hash-verified

18444//asks for $scope to fool the BC controller module
18445FormController.$inject = ['$element', '$attrs', '$scope', '$animate', '$interpolate'];
18446function FormController(element, attrs, $scope, $animate, $interpolate) {
18447 var form = this,
18448 controls = [];
18449
18450 var parentForm = form.$$parentForm = element.parent().controller('form') || nullFormCtrl;
18451
18452 // init state
18453 form.$error = {};
18454 form.$$success = {};
18455 form.$pending = undefined;
18456 form.$name = $interpolate(attrs.name || attrs.ngForm || '')($scope);
18457 form.$dirty = false;
18458 form.$pristine = true;
18459 form.$valid = true;
18460 form.$invalid = false;
18461 form.$submitted = false;
18462
18463 parentForm.$addControl(form);
18464
18465 /**
18466 * @ngdoc method
18467 * @name form.FormController#$rollbackViewValue
18468 *
18469 * @description
18470 * Rollback all form controls pending updates to the `$modelValue`.
18471 *
18472 * Updates may be pending by a debounced event or because the input is waiting for a some future
18473 * event defined in `ng-model-options`. This method is typically needed by the reset button of
18474 * a form that uses `ng-model-options` to pend updates.
18475 */
18476 form.$rollbackViewValue = function() {
18477 forEach(controls, function(control) {
18478 control.$rollbackViewValue();
18479 });
18480 };
18481
18482 /**
18483 * @ngdoc method
18484 * @name form.FormController#$commitViewValue
18485 *
18486 * @description
18487 * Commit all form controls pending updates to the `$modelValue`.
18488 *
18489 * Updates may be pending by a debounced event or because the input is waiting for a some future
18490 * event defined in `ng-model-options`. This method is rarely needed as `NgModelController`
18491 * usually handles calling this in response to input events.
18492 */
18493 form.$commitViewValue = function() {
18494 forEach(controls, function(control) {
18495 control.$commitViewValue();
18496 });
18497 };
18498
18499 /**
18500 * @ngdoc method
18501 * @name form.FormController#$addControl
18502 *
18503 * @description

Callers

nothing calls this directly

Calls 5

$interpolateFunction · 0.70
forEachFunction · 0.70
assertNotHasOwnPropertyFunction · 0.70
arrayRemoveFunction · 0.70
addSetValidityMethodFunction · 0.70

Tested by

no test coverage detected