Reputation: 21817
I have simple angular
web application and form on it. Form contains 2 <input>
and 1 <p>
elements. p
value is angular
template:
<p>{{status()}}</p>
$scope.status = function(){
alert('p');
return 'Some status';
}
When page loaded all displays normally i see alert and 'Some status'
in my <p>
. But I have a question. When i try to input something to the <input>
, i see alert('p')
again and again every time when i typing any symbol to the input
? Why?
Thank you.
Upvotes: 0
Views: 372
Reputation: 18542
I guess you have an input with ng-model. When your input is modified, the model is changed. After each change, angular runs the digest, which reevaluates all the expressions in the view (technically it processes the watch list). You should read about it in the Angular concepts in the Angular developer guide.
Upvotes: 3
Reputation: 2613
I think that you also have data binding on your input that's why angular is validating the scope each time you change something with key input and the alert is called because angular has to execute the function to check if the value returned is still the same.
Upvotes: 2