Skip to content

Instantly share code, notes, and snippets.

Created May 13, 2016 00:09
Show Gist options
  • Save anonymous/cdaa4b4f20a38f1f6924910db6f26b43 to your computer and use it in GitHub Desktop.
Save anonymous/cdaa4b4f20a38f1f6924910db6f26b43 to your computer and use it in GitHub Desktop.
JS Bin GroupBy example using angular.filter // source http://jsbin.com/vucivacuqa
<!DOCTYPE html>
<html ng-app="app">
<head>
<script src="https://code.jquery.com/jquery.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.22/angular.min.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/angular-filter/0.4.7/angular-filter.js"></script>
<meta name="description" content="GroupBy example using angular.filter"/>
<meta charset="utf-8">
<title>JS Bin</title>
</head>
<body>
<div ng-controller="MainController">
<ul ng-repeat="(key, value) in players | groupBy: 'date'" class="list-group">
<li class="list-group-item active">
<h4>Group name: {{ key }}</h4>
</li>
<li ng-repeat="person in value" class="list-group-item">
person:
{{ person.data.name }} <br>
{{ person.data.email }}
</li>
</ul>
</div>
<script id="jsbin-javascript">
angular.module('app',['angular.filter'])
.controller('MainController', function($scope) {
$scope.players = [
{
date: "10-15-2016",
data : {
name : "Jayesh",
email: "jaycp@gmail.com"
}
},
{
date: "10-15-2016",
data : {
name : "Mona",
email: "mona.c@gmail.com"
}
},
{
date: "10-18-2016",
data : {
name : "Bobby",
email: "bobby.m@gmail.com"
}
}
];
});
</script>
<script id="jsbin-source-html" type="text/html"><!DOCTYPE html>
<html ng-app="app">
<head>
<script src="https://code.jquery.com/jquery.min.js"><\/script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.22/angular.min.js"><\/script>
<script src="//cdnjs.cloudflare.com/ajax/libs/angular-filter/0.4.7/angular-filter.js"><\/script>
<meta name="description" content="GroupBy example using angular.filter"/>
<meta charset="utf-8">
<title>JS Bin</title>
</head>
<body>
<div ng-controller="MainController">
<ul ng-repeat="(key, value) in players | groupBy: 'date'" class="list-group">
<li class="list-group-item active">
<h4>Group name: {{ key }}</h4>
</li>
<li ng-repeat="person in value" class="list-group-item">
person:
{{ person.data.name }} <br>
{{ person.data.email }}
</li>
</ul>
</div>
</body>
</html></script>
<script id="jsbin-source-javascript" type="text/javascript">angular.module('app',['angular.filter'])
.controller('MainController', function($scope) {
$scope.players = [
{
date: "10-15-2016",
data : {
name : "Jayesh",
email: "jaycp@gmail.com"
}
},
{
date: "10-15-2016",
data : {
name : "Mona",
email: "mona.c@gmail.com"
}
},
{
date: "10-18-2016",
data : {
name : "Bobby",
email: "bobby.m@gmail.com"
}
}
];
});</script></body>
</html>
angular.module('app',['angular.filter'])
.controller('MainController', function($scope) {
$scope.players = [
{
date: "10-15-2016",
data : {
name : "Jayesh",
email: "jaycp@gmail.com"
}
},
{
date: "10-15-2016",
data : {
name : "Mona",
email: "mona.c@gmail.com"
}
},
{
date: "10-18-2016",
data : {
name : "Bobby",
email: "bobby.m@gmail.com"
}
}
];
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment