I am using method inside a template to call the function, that returns boolean
value. The issue is that the function is called more than 6 times. After that I used changeDetectionStrategy.onPush
which reduced the calls to 2 times. Below is my code
HTML
<div *ngIf="(checkboolObs(check$)) | async"></div>
TS
check$: Observable<service> = this.data.getresponse();
ngOnInit() {
this.checkboolObs();
}
checkboolObs(style):boolean {
return somestyleIDS.includes(style.component)
}
If the value is found it returns true
, but it is called several times i need to call it only once. The reason behind this is because checkboolobs()
is not triggered some times while navigating that's why I am calling this method from the template.