Question

I'm trying to multiple a value x months.

In the input value i'm using this Jquery Plugin to do the currency mask.

But, the operations doesn't work with the plugin. I want to multiply the value, including cents.

JSFIDDLE

<div ng-app>
Months: <input type="text" ng-model="months"><br/>
Value:<input type="text" class="mony" ng-model="value"><br/>
Total: <input type="text" disabled="true" value="{{months*value | currency}}">
</div>
Was it helpful?

Solution

In your case the value becomes formatted string that is not understood as a number. So multiplication does not work.

In Angular it is discouraged to use jQuery to modify DOM, all modifications should be done from Directives. So the best solution is to find the formater directive or create your own. Just search for something like "angularjs mask input".

Or maybe you can create controller and one of its methods will parse your string back into Number. If you still want to stick with jQuery without directive.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top