Multiply calls


#1

I did created blank project.

export class HomePage {

  i = 0;

  constructor(public navCtrl: NavController) {

  }

  test() {
    console.log('call', this.i++);
  }



}

my home.html:

<ion-content padding>
<div>
  {{test()}}
</div>
...

My question.
Why I see in console call method 9 times?

call 0
call 1
...
call 8

thanks.


#2

declare the variable

i *= i++;

test() {
console.log(‘call’, this.i);
}


#3

Dont interpolate function calls. U will have no control on how often it is called.

Use: {{i}} and a button element to trigger addition in method test

Check angulars doc on template syntax if u want to avoid future pitfalls. Google: angular template syntax