Filter a List of DOM Nodes

Description

The following code shows how to filter a List of DOM Nodes.

Example


<!doctype html>
<html  ng-app="MyApp">
<head>
  <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.2/angular.js"></script>
    <script>
var app   =  angular.module("MyApp", []);
<!-- w  w  w .j  a v a2s . c  om-->
 app.filter("exclude",  function() {
      return  function(input,  exclude) {
           var result  =  [];
           for (var i=0; i<input.length;  i++)  {
                if (input[i]  !==  exclude)  {
                     result.push(input[i]);
                }
           }

           return  result;
      };
 });  
    </script>
  </head>
  <body>
     <ul ng-init="names =  ['A',  'B',  'C']"> 
          <li  ng-repeat="name in  names   | exclude:'B' ">
               <span>{{name}}</span>
          </li>
     </ul>

  </body>
</html>

Click to view the demo





















Home »
  AngularJS »
    AngularJS Example »




Controller
Directives
Expression
Filter
Form
Inject
Scope
Server
Style
Template
Utilities