Here, In this example An observable is emitting values. But in console output, zeros after decimals are removed automatically.
I want to keep these zeros as it as after decimal. Is there a way to keep this zeros?
const numbers$ = of(1.440000, 2.40000, 3.0000);
numbers$.subscribe(
value => console.log('Observable emitted the next value- ' + value)
);
Output:
Observable emitted the next value- 1.44 // need output as 1.440000
Observable emitted the next value- 2.4 // need output as 2.40000
Observable emitted the next value- 3 // need output as 3.0000
This is not a rxjs issue, this is js behaviour.
To receive the desired outcome you can use
toFixedas seen here How to add a trailing zero to a price?. Keep in mind that this will cast the number to a string, so I would advise to add the "padding" zeroes as a last step, or even better by using the DecimalPipe in the templates, where you want to show the values.