Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
  • Custom Filters in AngularJS

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 287
    Comment on it

    Hope you are doing good today.
    Today on My blog, I am going to explain how you can create Custom Filters in AngularJS. Filters are an important part in AngularJS which used to format data

    First Create an index.html page and put required library file in  <head></head> section:

    <script src = ""></script>

    Here we are using ng-click directive, which changed the behavior when an element is clicked.

    <h1>Custome Sorting</h1>
    				<h2>short data by Name & Country</h2>
    				<div ng-app="myapp" ng-controller="mycnt"> 
    					<table border='1'>
    							<td ng-click="orderByMe('name')" ><b>Name</b></td>
    							<td  ng-click="orderByMe('country')"><b>Country</b></td>						
    						<tr ng-repeat="x in names | orderBy :myOrderBy" >
    							<td>{{$index + 1}}</td>

    AngularJS Script for shorting.

    <script type="text/javascript">
    var app=angular.module('myapp', []);
    	 app.controller('mycnt', function($scope) {  
    	 	//Assign the value 
         $scope.names = [  
      //send the value to orderByMe
        $scope.orderByMe = function(x) {  
            $scope.myOrderBy = x;  

    I hope this will help you. Please feel free to give us your feedback in comments.

 0 Comment(s)

Sign In

Sign up using

Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: