From f59e4b11f11261c234a821db67088f0de88a2852 Mon Sep 17 00:00:00 2001 From: Igor Minar Date: Mon, 12 Mar 2012 21:12:15 -0700 Subject: fix(forms): prefix all form and control properties with $ --- docs/content/cookbook/advancedform.ngdoc | 2 +- docs/content/guide/dev_guide.forms.ngdoc | 34 ++++++++++++++++---------------- 2 files changed, 18 insertions(+), 18 deletions(-) (limited to 'docs/content') diff --git a/docs/content/cookbook/advancedform.ngdoc b/docs/content/cookbook/advancedform.ngdoc index 3e3b2d28..58a8dfd5 100644 --- a/docs/content/cookbook/advancedform.ngdoc +++ b/docs/content/cookbook/advancedform.ngdoc @@ -52,7 +52,7 @@ detection, and preventing invalid form submission. }; $scope.isSaveDisabled = function() { - return $scope.myForm.invalid || angular.equals(master, $scope.form); + return $scope.myForm.$invalid || angular.equals(master, $scope.form); }; $scope.cancel(); diff --git a/docs/content/guide/dev_guide.forms.ngdoc b/docs/content/guide/dev_guide.forms.ngdoc index c79b9683..8cb0d4fe 100644 --- a/docs/content/guide/dev_guide.forms.ngdoc +++ b/docs/content/guide/dev_guide.forms.ngdoc @@ -162,9 +162,9 @@ stored on the `FormController`.
@@ -214,10 +214,10 @@ function gets fourth argument - an instance of `NgModelController`, which is a c to `ng-model`, that allows you to hook into the validation process. ## Model to View update -Whenever the bound model changes, all functions in {@link api/angular.module.ng.$compileProvider.directive.ng:model.NgModelController#formatters NgModelController#formatters} array are pipe-lined, so that each of these functions has an opportunity to format the value and change validity state of the form control through {@link api/angualar.module.ng.$compileProvider.directive.ng:model.NgModelController#setValidity NgModelController#setValidity}. +Whenever the bound model changes, all functions in {@link api/angular.module.ng.$compileProvider.directive.ng:model.NgModelController#formatters NgModelController#formatters} array are pipe-lined, so that each of these functions has an opportunity to format the value and change validity state of the form control through {@link api/angualar.module.ng.$compileProvider.directive.ng:model.NgModelController#$setValidity NgModelController#$setValidity}. ## View to Model update -In a similar way, whenever a form control calls {@link api/angular.module.ng.$compileProvider.directive.ng:model.NgModelController#setViewValue NgModelController#setViewValue}, all functions in {@link api/angular.module.ng.$compileProvider.directive.ng:model.NgModelController#parsers NgModelController#parsers} array are pipe-lined, so that each of these functions has an opportunity to correct/convert the value and change validity state of the form control through {@link api/angualar.module.ng.$compileProvider.directive.ng:model.NgModelController#setValidity NgModelController#setValidity}. +In a similar way, whenever a form control calls {@link api/angular.module.ng.$compileProvider.directive.ng:model.NgModelController#setViewValue NgModelController#setViewValue}, all functions in {@link api/angular.module.ng.$compileProvider.directive.ng:model.NgModelController#parsers NgModelController#parsers} array are pipe-lined, so that each of these functions has an opportunity to correct/convert the value and change validity state of the form control through {@link api/angualar.module.ng.$compileProvider.directive.ng:model.NgModelController#setValidity NgModelController#$setValidity}. In this example we create two simple directives. The first one is `integer` and it validates whether the input is valid integer, so for example `1.23` is an invalid value. Note, that we unshift the array instead of pushing - that's because we want to get a string value, so we need to execute the validation function before a conversion to number happens. @@ -230,13 +230,13 @@ The second directive is `smart-float`. It parses both `1.2` and `1,2` into a val @@ -249,14 +249,14 @@ The second directive is `smart-float`. It parses both `1.2` and `1,2` into a val return { require: 'ngModel', link: function(scope, elm, attrs, ctrl) { - ctrl.parsers.unshift(function(viewValue) { + ctrl.$parsers.unshift(function(viewValue) { if (INTEGER_REGEXP.test(viewValue)) { // it is valid - ctrl.setValidity('INTEGER', true); + ctrl.$setValidity('INTEGER', true); return viewValue; } else { // it is invalid, return undefined (no model update) - ctrl.setValidity('INTEGER', false); + ctrl.$setValidity('INTEGER', false); return undefined; } }); @@ -269,12 +269,12 @@ The second directive is `smart-float`. It parses both `1.2` and `1,2` into a val return { require: 'ngModel', link: function(scope, elm, attrs, ctrl) { - ctrl.parsers.unshift(function(viewValue) { + ctrl.$parsers.unshift(function(viewValue) { if (FLOAT_REGEXP.test(viewValue)) { - ctrl.setValidity('FLOAT', true); + ctrl.$setValidity('FLOAT', true); return parseFloat(viewValue.replace(',', '.')); } else { - ctrl.setValidity('FLOAT', false); + ctrl.$setValidity('FLOAT', false); return undefined; } }); @@ -308,7 +308,7 @@ This example shows how easy it is to add a support for binding contentEditable e // view -> model elm.bind('blur', function() { scope.$apply(function() { - ctrl.setViewValue(elm.html()); + ctrl.$setViewValue(elm.html()); }); }); @@ -318,7 +318,7 @@ This example shows how easy it is to add a support for binding contentEditable e }; // load init value from DOM - ctrl.setViewValue(elm.html()); + ctrl.$setViewValue(elm.html()); } }; }); -- cgit v1.2.3