0

I am simply trying to achieve this calculation:

{{(this.buyForm.value.rate * this.buyForm.value.Units)}}

Now, rate will have values in decimal places like 0.00003095 * 0.03004 like this.

Now with multiplication, I would like to control it with 8 decimal points.

I tried using decimal pipe like:

{{(this.buyForm.value.rate * this.buyForm.value.Units)|number:'1.8-8'}}

{{(this.buyForm.value.rate * this.buyForm.value.Units)|round}} but nothing is working in my case.

8
  • 1
    "Nothing is working" ... do you get a wrong output or an exception ?
    – Safiyya
    Commented Mar 26, 2018 at 16:38
  • I get 0 value only Commented Mar 26, 2018 at 16:39
  • Have you tried it with no pipe at all, just to make sure the value isn't actually 0?
    – kshetline
    Commented Mar 26, 2018 at 16:41
  • yes, it comes with uncontrolled decimal points Commented Mar 26, 2018 at 16:42
  • This seems to work okay for me: stackblitz.com/edit/angular-tzsbxp Commented Mar 26, 2018 at 16:43

1 Answer 1

3

You dont need to add this to bind your properties in the HTML template :

Try

{{(buyForm.value.rate * buyForm.value.Units)|number:'1.8-8'}}

instead of

{{(this.buyForm.value.rate * this.buyForm.value.Units)|number:'1.8-8'}}

Not the answer you're looking for? Browse other questions tagged or ask your own question.