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

Document difference between ng-change and JavaScript onchange #5640

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions src/ng/directive/input.js
Original file line number Diff line number Diff line change
Expand Up @@ -1232,7 +1232,10 @@ var ngModelDirective = function() {
* @name ng.directive:ngChange
*
* @description
* Evaluate given expression when user changes the input.
* Evaluate the given expression when the user changes the input.
* The expression is evaluated immediately, unlike the JavaScript onchange event
* which only triggers at the end of a change (usually, when the user leaves the
* form element or presses the return key).
* The expression is not evaluated when the value change is coming from the model.
*
* Note, this directive requires `ngModel` to be present.
Expand All @@ -1253,11 +1256,10 @@ var ngModelDirective = function() {
* }
* </script>
* <div ng-controller="Controller">
* <input type="checkbox" ng-model="confirmed" ng-change="change()" id="ng-change-example1" />
* <input type="checkbox" ng-model="confirmed" id="ng-change-example2" />
* <label for="ng-change-example2">Confirmed</label><br />
* debug = {{confirmed}}<br />
* counter = {{counter}}
* <label for="a">Field a:</label> <input type="text" ng-model="text" id="a" ng-change="change()" /><br />
* <label for="b">Field b:</label> <input type="text" ng-model="text" id="b" />
* Text: {{text}}<br />
* Number of changes through field a: {{counter}}
* </div>
* </doc:source>
* <doc:scenario>
Expand Down