In app.component.ts
, I assign a value to a property in onInit, and it used in html.
data:any = [];
ngOnInit() {
this.service.getData().subscribe(res => this.data = res);
}
Any idea why ngOnInit()
calls more than once?
At first, I thought it was the request interface causing this issue. However, after some attempts, I found that assigning a value to it during the lifecycle causes the problem.