Angularjs custom filters tutorial

Angularjs custom filters:

AngularJS provides the facility to create the custom filters. Custom filters are created using “filter” function.

Example Explanation:

The ng-app directive initializes the application. We create a testFilter which reverse the string and capitalize the first letter.


<!DOCTYPE html>
 <div ng-app="testApp" ng-controller="appCtrl">
   Welcome to {{ name | testFilter }}
   var app = angular.module('testApp', []);
      app.controller('appCtrl', function($scope) {
          $ = "tutorialspointexamples"
      return function( str ) {
        var revStr = str.split('').reverse();
        return revStr[0].toUpperCase() + revStr.join('').slice(1);

Try it:

JS Bin on

Comments are closed.