In Angular you can create a formatting function, and then instead of directly outputting the variable, output 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, just leave two decimal places. This could be done with a simple function:
function formateaValor(valor) {
// si no es un número devuelve el valor, o lo convierte a número con 2 decimales
return isNaN(valor) ? valor : parseFloat(valor).toFixed(2);
}
That you can integrate in AngularJS as follows:
var app = angular.module("miApp", []);
app.controller("miCtrl", function($scope) {
$scope.array = ["paco", "185.6687", "lucas", "1365.2541"];
$scope.miFormato = function(valor) {
return isNaN(valor) ? valor : parseFloat(valor).toFixed(2);
}
});
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<body ng-app="miApp" ng-controller="miCtrl">
<div ng-repeat="val in array">
{{ miFormato(val) }}
</div>
</body>