Skip to content

Instantly share code, notes, and snippets.

@perminder-klair
Created February 27, 2015 15:59
Show Gist options
  • Save perminder-klair/eb76fa31cb3b31a36df9 to your computer and use it in GitHub Desktop.
Save perminder-klair/eb76fa31cb3b31a36df9 to your computer and use it in GitHub Desktop.
AngularJs Ng Repeat Filter
<!DOCTYPE html>
<html>
<head>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.3.2/angular.min.js"></script>
<script>
angular.module('ngAnimate', [])
.controller('MyCtrl', ['$scope', function ($scope) {
console.log('works');
$scope.friends = [
{name:'John', age:25, gender:'boy'},
{name:'Jessie', age:30, gender:'girl'},
{name:'Johanna', age:28, gender:'girl'},
{name:'Joy', age:15, gender:'girl'},
{name:'Mary', age:28, gender:'girl'},
{name:'Peter', age:95, gender:'boy'},
{name:'Sebastian', age:50, gender:'boy'},
{name:'Erika', age:27, gender:'girl'},
{name:'Patrick', age:40, gender:'boy'},
{name:'Samantha', age:60, gender:'girl'}
];
var ages = [25, 28];
$scope.filterFn = function(data) {
// Do some tests
//if (data.age)
if (ages.indexOf(data.age) != '-1') {
return true;
}
return false;
};
}]);
</script>
<meta charset="utf-8">
<title>JS Bin</title>
</head>
<body ng-app="ngAnimate">
<div ng-controller="MyCtrl">
<ul class="example-animate-container">
<li class="animate-repeat" ng-repeat="friend in friends | filter:filterFn">
[{{$index + 1}}] {{friend.name}} who is {{friend.age}} years old.
</li>
<li class="animate-repeat" ng-if="results.length == 0">
<strong>No results found...</strong>
</li>
</ul>
</div>
</body>
</html>
@jamessmith999000
Copy link

Hello sir, I want to develop a music website. I want API key of blugaa.com. It is my favourite music portal. You can contact me on jamessmith999000@gmail.com. Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment