Multiply calls

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.

declare the variable

i *= i++;

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

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

1 Like