I'm tackling a pretty straightforward task here. I just need to integrate a currency filter into the custom filter that I coded.
Take a look at the code snippet below:
var app = angular.module('testapp', []);
app.controller('MainCtrl', function() {
this.people = [{
name: 'James',
bank: 5285
}, {
name: 'Mary',
bank: 849
}];
});
app.filter('richmeter', function() {
return function(bank) {
if (bank > 2500) {
return bank + ' [RICH]'
} else {
return bank;
}
}
});
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<div ng-app="testapp">
<div ng-controller="MainCtrl as vm">
<div ng-repeat="people in vm.people | filter:richmeter">
{{people.name}} has {{people.bank | currency }}
</div>
</div>
</div>
What am I missing here? Why isn't it functioning as expected?
Your guidance is much appreciated.