I have encountered a problem assigning an element's value to a service. In this scenario, the value of the component is populated with the result of the response from the server. But this calling service falls in a loop and the site ultimately crashes.
This is my component.cs code:
count = -1;
constructor(
private formBuilder: FormBuilder,
private referralService: ReferralService
) { }
getCount() {
this.referralService
.getAll()
.pipe(first())
.subscribe((response) => {
this.count = response.data;
});
return this.count;
}
And this is my component.html:
<div class="alert alert-success" role="alert" style="width: 100%">
<div class="b" style="display: flex">
You have
<div style="padding-left: 5px; padding-right: 5px">{{getCount()}}</div>
counts right now
</div>
</div>
Because of unknown reasons this getCount() is called countless times.