I am calling a function from inside an angular template (interpolation), strangely the function is getting invoked four times !!
I do know how change detection works in angular, as I understood change-detection process kickstarts if binding value gets updated.
In this scenario, I am not binding / changing any thing as such..
var i = 0;
@Component({
selector: 'my-app',
template: `
<div>
<h1>{{ parentCounter() }}</h1>
</div>
`,
})
export class App {
name:string;
constructor() {
}
parentCounter(){
alert(`${++i} called`);
return 5;
}
}
Ref: https://plnkr.co/edit/pta0s0nzcsLdTsjCtb3D?p=preview
Note: Template got compiled four times before the async event