<!DOCTYPE html>
<html>
<head>
<script src="Scripts/angular.min.js"></script>
</head>
<body style="font-family:Arial; font-size:medium; color:darkblue">
<div ng-app="myModule">
<h3>Custom filter in AngularJS</h3>
<br/>
Enter the text : <input type="text" ng-model="inputText"/>
<br/><br/>
Reverse string :{{inputText|reverseString}}
</div>
<script>
//Create a module
var myApp = angular.module("myModule", []);
//Create a custom Filter name reverseString.
myApp.filter("reverseString", function ()
{
//Defining the filter function
returnfunction (input)
{
var result = "";
input = input || "";
for (vari = 0; i<input.length; i++)
{
result = input.charAt(i) + result;
}
return result;
};
});
</script>
</body>
</html>