JS code:
$scope.records={"0.19", "C:0.13", "C:0.196|D:0.23"}
.filter('filterOutput', function () {
return function (input) {
if (input.indexOf(":") != -1) {
var out = input
.split('|')
.map(function (v) {
var s = v.split(':')
return s[0] + ':' + (Number(s[1]) * 100) + "%"
})
.join()
return out;
} else {
return input * 100 + "%";
}
}
})
HTML code:
<h1 ng-repeat="x in records|filterOutput">{{x}}</h1>
I want output:
"19%"
"C:13%""C:19.6%|D:23%"
But console.log:
TypeError: input.indexOf is not a function
What should I do? How to split the data in AngularJS?