Array Filters
Filter concepts used for arrays
by manoj_antony32
HTML
<h4>Selects a subset of items from array and returns it as a new array.</h4>
<div ng-app="CurrencyApp" ng-controller="CurrencyController">
<input type="text" ng-model="searchTodos" />
<table class="table table-striped table-bordered">
<thead>
<tr>
<th>#</th>
<th>Title</th>
<th>Description</th>
<th>Done?</th>
<th>Date</th>
</tr>
</thead>
<tbody>
<!--<tr ng-repeat="todo in todos | filter:searchTodos">-->
<!--<tr ng-repeat="todo in todos | filter: {title : searchTodos, done: true}"> $ means all fields-->
<!--<tr ng-repeat="todo in todos | filter: {$ : searchTodos} | limitTo : 3: 1">{{ object | limitTo : limit : begin }}-->
<tr ng-repeat="todo in todos | filter: {$ : searchTodos}">
<td>{{$index + 1}}</td>
<td>{{todo.title}}</td>
<td>{{todo.description}}</td>
<td>{{todo.done}}</td>
<td>{{todo.date | date}}</td>
</tr>
</tbody>
</table>
</div>
JavaScript
var myApp = angular.module('CurrencyApp', []);
myApp.controller("CurrencyController", ['$scope', function($scope) {
$scope.todos = [
{id: 1,title: 'Learn AngularJS', description: 'Learn AngularJS', done: true, date: new Date()} ,
{id: 2,title: 'Explore ui-router', description: 'Explore and use ui-router instead of ngRoute', done: true, date: new Date()} ,
{id: 3,title: 'Play with Restangular', description: 'Restangular seems better than $resource, have a look', done: false, date: new Date()} ,
{id: 4,title: 'Try yeoman', description: 'No more labour work..use Yeoman', done: false, date: new Date()} ,
{id: 5,title: 'Try MEANJS', description: 'Aah..MEANJS stack seems cool..why dont u try once', done: false, date: new Date()}
];
}]);