Created
February 20, 2015 16:31
-
-
Save spirinvladimir/270c220758420621b52a to your computer and use it in GitHub Desktop.
AngularJS template help
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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