I have the following js:
var array = ["paco", "185.6687", "lucas", "1365.2541"]
<div ng-repeat="val in array">
{{val}}
</div>
I know that if it were a number, it would {{val | number:2}}
work, but if I have that array, how do I make it so that it only shows me 2 decimal places?
In Angular you can create a formatting function, and then instead of directly outputting the variable, output it to the formatting function (passing the variable as an input parameter).
In your particular case, you want a function that if the input is a string, leave it as such, but if it is a number, only leave two decimal places. This could be done with a simple function:
You can integrate this into AngularJS as follows:
So it will only catch you 2 decimals.
Something like this sounds like it might work for you