0

I have an issue where I need to essentially do math on the fly and not a function. I have 3 elements that need to be multiplied and have yet to find a solution. I have added the element "number:2" but that only pertains to the elements being multiplied and not to the whole sum. Below I have my current code.

 <input disabled name='e_total{{$index}}' type='text' id='e_total{{$index}}' value='{{ (item.quantity | number:2)  * (item.cost | number:2) * (item.markup | number:2)}}'/>

Is there a way to do this with binding? I have also changed my input type to number but that does not seem to work. Thanks for any direction.

  • I think this will probably answer your question: http://stackoverflow.com/questions/12740329/math-functions-in-angular-bindings – Mic Dec 29 '15 at 17:15

1 Answers1

0

You can filter at the end like: {{ vm.item.quantity * vm.item.cost * vm.item.markup | number:2 }}

full example: http://jsfiddle.net/tjruzpmb/197/

ChrisY
  • 1,681
  • 10
  • 12
  • Thank you. Your idea seems to work, but for whatever reason it doesn't on my end. Not sure if I have some other issue going on. Doesn't throw an error either. – jcdevelopment Dec 29 '15 at 17:39