I am working on a custom pipe that converts a given number into days and hours. The HTML code for this pipe is as follows:
<div *ngFor="let unit of units">
<p>Remaining Life</p>
<h2>{{ unit.daysRemaining | timeRemaining }}</h2>
</div>
Initially, the unit
object was located within the component, and the pipe successfully converted the number. You can view it in action on this StackBlitz link.
However, I decided to load the data using a service, and that's when the values started showing as undefined
(I have set it up to display as 0 in the pipe). Take a look at the outcome in this modified StackBlitz.
What could be causing this discrepancy between the two scenarios? Why does the value turn into undefined
when retrieving data from a service?