Skip to content

Commit 120f88e

Browse files
shahataCameron Knight
authored and
Cameron Knight
committed
docs(ngModel): objects passed to $setViewValue should be copied
Closes angular#8095
1 parent 80880d0 commit 120f88e

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/ng/directive/input.js

+7-3
Original file line numberDiff line numberDiff line change
@@ -1577,7 +1577,9 @@ var NgModelController = ['$scope', '$exceptionHandler', '$attrs', '$element', '$
15771577
*
15781578
* @description
15791579
* Called when the view needs to be updated. It is expected that the user of the ng-model
1580-
* directive will implement this method.
1580+
* directive will implement this method. Note that in case `$modelValue` is an object,
1581+
* this method will be invoked only if a different instance is assigned to the model since
1582+
* `ngModel` does not perform a deep watch of objects.
15811583
*/
15821584
this.$render = noop;
15831585

@@ -1879,8 +1881,10 @@ var NgModelController = ['$scope', '$exceptionHandler', '$attrs', '$element', '$
18791881
* Update the view value.
18801882
*
18811883
* This method should be called when the view value changes, typically from within a DOM event handler.
1882-
* For example {@link ng.directive:input input} and
1883-
* {@link ng.directive:select select} directives call it.
1884+
* For example {@link ng.directive:input input} and {@link ng.directive:select select}
1885+
* directives call it. In case the view value is an object, this method should be called with a
1886+
* copy of that object since `ngModel` does not perform a deep watch of objects. Properties of
1887+
* that copy should not be changed after `$setViewValue` in invoked.
18841888
*
18851889
* It will update the $viewValue, then pass this value through each of the functions in `$parsers`,
18861890
* which includes any validators. The value that comes out of this `$parsers` pipeline, be applied to

0 commit comments

Comments
 (0)