Special filters in angularJS

The 'new' way of filtering in angularJS since version 1.idontknow. There're some kind of special ways.

by Shaun Luttin

HTML

<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.1.4/angular.min.js"></script>
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/css/bootstrap-combined.min.css">
<div ng-app="testApp">
    <div ng-controller="excludeInactiveCtrl">
         <h4>exclude inactive?</h4>
        only show active: <input type="checkbox" ng-model="showActive" /> ngmodel value: {{showActive}}
        <table class="table table-condensed table-hover">
            <thead>
                <tr>
                    <th>Name</th>
                    <th>Active</th>
                </tr>
            </thead>
            <tbody>
                <tr ng-repeat="o in data | filter:{active:showActive}">
                    <td>{{o.name}}</td>
                    <td>{{o.active}}</td>
                </tr>
            </tbody>
        </table>
    </div>
</div>

CSS

body {
    padding:20px;
}

JavaScript

angular.module('testApp', []).
controller('excludeInactiveCtrl', ['$scope', function ($scope) {
    //example 1 just normal filtering on boolean value
    $scope.data = [{name:'Name1',active:true},
                   {name:'Name2',active:false},
                   {name:'Name3',active:true},
                   {name:'Name4',active:false},
                   {name:'Name5',active:true}];
}]);