Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

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.

share|improve this question
    
Which <input> are you referring to? –  callmekatootie May 23 '13 at 8:54
    
I have just 2 <input> in forms, but they not in any way related to the p –  0xAX May 23 '13 at 8:58

2 Answers 2

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.

share|improve this answer

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.