There are times when my model.field
can be altered by both user input into an input field and by other functions running in the background. However, I want to handle situations where changes made by the user take precedence over modifications made by those background functions. For instance:
$scope.model = {
field: 'val1'
}
This is the HTML code:
<input ng-model="model.field" ...>
For example:
- The initial value of
model.field
is 'val1' - The user begins editing the input (it becomes active)
- While the user is typing, the model updates to 'val2' through a background function
- Despite the change in the model, the input still displays 'val1'
- Any key pressed by the user during this time (from 1 to A) replaces the current content in
model.field
. - As a result, the new value of
model.field
becomes 'valA'