Skip to content

Instantly share code, notes, and snippets.

@spirinvladimir
Created February 20, 2015 16:31
Show Gist options
  • Save spirinvladimir/270c220758420621b52a to your computer and use it in GitHub Desktop.
Save spirinvladimir/270c220758420621b52a to your computer and use it in GitHub Desktop.
AngularJS template help
var locationtApp = angular.module('locationApp', []);
locationtApp.controller('LocationListCtrl', ['$scope', function ($scope) {
var phones = [
{
'src': 'http://localhost/images/image1.jpg'
},
{
'src': 'http://localhost/images/image2.jpg'
},
{
'src': 'http://localhost/images/image3.jpg'
},
{
'src': 'http://localhost/images/image4.jpg'
},
{
'src': 'http://localhost/images/image5.jpg'
},
{
'src': 'http://localhost/images/image6.jpg'
},
{
'src': 'http://localhost/images/image7.jpg'
}
],
groups = [];
phones.forEach(function (phone, i) {
var key = Math.floor(i / 4);
if (typeof groups[key] === 'object') {
groups[key].push(phone);
} else {
groups[key] = [phone];
}
});
$scope.groups = groups;
}]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment