Myapp.filter (‘name of filter’, function () { return function (input, optparameter1, optparameter2) { var out; //code for the implementation of custom filter can be put here return out; } }) Myapp.filter('toUpperCase', function () { return function (in) { var out = ""; out = in.toUpperCase(); return out; } }) Myapp.controller("Product Controller", function ($scope) { $scope.products = [ { 'name': 'pencil', 'price': '250' }, { 'name': 'pen', 'price': '300' }, { 'name': 'book', 'price': '3400' }, { 'name': 'sharpener', 'price': '100' }, { 'name': 'bat', 'price': '7000' }, ]; }) Myapp.filter('toPositionUpperCase', function () { return function (in,position) { var out = []; var CapLetter = in.charAt(position).toUpperCase(); for (var j = 0; j < in.length; j++) { if (j == position) { out.push(CapLetter); } else { out.push(input[j]); } } out = out.join(''); return out; } }) Myapp.filter('priceGreaterThan', function () { return function (in, price) { var out = []; if (isNaN(price)) { out = in; } else { angular.forEach(in, function (item) { if (item.price > price) { out.push(item) } }); } return out; } })

With Custom Filter Implementation


{{b.name}} {{b.price}}