Angular 2 PercentPipe unusual output
Asked Answered
T

1

5

The following bindings:

{{ -50.52338914680037 }}
{{ -50.52338914680037 | number }}
{{ -50.52338914680037 | percent }}

Produce:

-50.52338914680037
-50.523
-5,052.339%

I would anticipate the output of the percent pipe to be

-50.523%

Is there something I'm missing?

Travel answered 17/2, 2017 at 6:19 Comment(0)
K
11

To get your anticipated result of -50.523% use this code:

{{ (-50.52338914680037 / 100) | percent }}

or

{{ -0.5052338914680037 | percent:'2.0-3' }}

Have a look at the DecimalPipe (API) for format adjustments if needed.

Kevinkevina answered 17/2, 2017 at 7:6 Comment(2)
Well that's the default format anyway yeah? At any rate, even with it specified it, I get the same result: -5, 052.339%.Travel
Oh geez...Yep sorry, can't believe I've missed that.Travel

© 2022 - 2024 — McMap. All rights reserved.