I am new to AngularJS and got stuck into this complex thing. I have to make a filter on HTML input which will accept the currency in digits (no alphabets), a comma should be implemented automatically after 3 digits, decimal should be there and should append dollar sign on the left.
I have tried a lot but results are not coming which are required.I made this JavaScript function which does the same thing but how I will implement this in AngularJS while typing in the input box.
function formatPera(num) {
var p = num.toFixed(2).split(".");
return p[0].split("").reverse().reduce(function(acc, num, i, orig) {
return num + (i && !(i % 3) ? "," : "") + acc;
}, "") + "." + p[1];
}
var money = 1234;
money = formatPera(money);
console.log(money);
I have already searched a lot and checked the already deployed code.