Kumar
Kumar

Reputation: 307

How to pass variable in angular Pipe

I need to show some definite number of decimal digit in my output [length of decimal digit is returned by stored procedure] and length of these decimal digits vary.However I do not need to care integer part it just decimal I have to worry about.Hence I used number pipe. This works fine till I pass hard coded value like this:

{{transaction.Rate| number :'.2-3'}}

It shows expected value: 713.753 [I do not care integer part]

However I have a field in transaction model called RateDecimal. I want to pass this field instead of '3' in above snippet.

{{transaction.Rate | number :'.2-`transaction.RateDecimal`'}}

It throws error. How to pass the same?Thanks for your help.

Upvotes: 2

Views: 3655

Answers (2)

dkaramazov
dkaramazov

Reputation: 204

I am adding my working example here:

{{transaction.ExchangeRate | number : '.2-' + transaction.CustomerRateDecimal}}

The above thing works for me as number pipe expects values in quotes for decimal part hence concatenate is playing good here.

Upvotes: 4

JC Ford
JC Ford

Reputation: 7066

Try this: {{transaction.Rate | number:transaction.RateDecimal}}

Upvotes: 1

Related Questions