Whenever a function is called in the view of an Angular component, it seems to be executed repeatedly. A typical example of this scenario can be seen below:
nightclub.component.ts
import { Component } from '@angular/core';
@Component({
selector: 'app-nightclub',
templateUrl: './nightclub.component.html',
styleUrls: ['./nightclub.component.css']
})
export class NightclubComponent {
doStuff(): number {
return 1;
}
}
nightclub.component.html
{{doStuff()}}
As observed, the doStuff() method is constantly being invoked.
Question:
Is it recommended to have functions called repeatedly in this manner? If so, under what circumstances could this practice prove to be advantageous?