manas
manas

Reputation: 6400

Why a method in expression is called two times in angular.js

I want to know why a method is called two times while it is used in angularjs binding expression.

you can find my code here at jsbin

why the callMe() method is called two times. I found the same question already posted but could not get a satisfactory answer. And if we want to avoid this to be called two times how to do it.

Upvotes: 1

Views: 64

Answers (1)

Poyraz Yilmaz
Poyraz Yilmaz

Reputation: 5857

You are binding a function to an expression

<p>{{callMe()}}</p>

that's why it's called many times, because it runs everytime when angularjs calls digest()... Here is a picture how digest work maybe it helps better...

enter image description here

Upvotes: 1

Related Questions