Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 5419201

Browse files
jubobagkalpak
authored andcommitted
docs(ngModel): fix example
For the example to work correctly, the initial model values have to be empty strings. Closes #15272
1 parent fcf182e commit 5419201

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

src/ng/directive/ngModel.js

+11-11
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,7 @@ NgModelController.prototype = {
451451
* angular.module('cancel-update-example', [])
452452
*
453453
* .controller('CancelUpdateController', ['$scope', function($scope) {
454-
* $scope.model = {};
454+
* $scope.model = {value1: '', value2: ''};
455455
*
456456
* $scope.setEmpty = function(e, value, rollback) {
457457
* if (e.keyCode === 27) {
@@ -466,8 +466,8 @@ NgModelController.prototype = {
466466
* </file>
467467
* <file name="index.html">
468468
* <div ng-controller="CancelUpdateController">
469-
* <p>Both of these inputs are only updated if they are blurred. Hitting escape should
470-
* empty them. Follow these steps and observe the difference:</p>
469+
* <p>Both of these inputs are only updated if they are blurred. Hitting escape should
470+
* empty them. Follow these steps and observe the difference:</p>
471471
* <ol>
472472
* <li>Type something in the input. You will see that the model is not yet updated</li>
473473
* <li>Press the Escape key.
@@ -484,17 +484,17 @@ NgModelController.prototype = {
484484
*
485485
* <form name="myForm" ng-model-options="{ updateOn: 'blur' }">
486486
* <div>
487-
* <p id="inputDescription1">Without $rollbackViewValue():</p>
488-
* <input name="value1" aria-describedby="inputDescription1" ng-model="model.value1"
489-
* ng-keydown="setEmpty($event, 'value1')">
490-
* value1: "{{ model.value1 }}"
487+
* <p id="inputDescription1">Without $rollbackViewValue():</p>
488+
* <input name="value1" aria-describedby="inputDescription1" ng-model="model.value1"
489+
* ng-keydown="setEmpty($event, 'value1')">
490+
* value1: "{{ model.value1 }}"
491491
* </div>
492492
*
493493
* <div>
494-
* <p id="inputDescription2">With $rollbackViewValue():</p>
495-
* <input name="value2" aria-describedby="inputDescription2" ng-model="model.value2"
496-
* ng-keydown="setEmpty($event, 'value2', true)">
497-
* value2: "{{ model.value2 }}"
494+
* <p id="inputDescription2">With $rollbackViewValue():</p>
495+
* <input name="value2" aria-describedby="inputDescription2" ng-model="model.value2"
496+
* ng-keydown="setEmpty($event, 'value2', true)">
497+
* value2: "{{ model.value2 }}"
498498
* </div>
499499
* </form>
500500
* </div>

0 commit comments

Comments
 (0)