Quantcast
Channel: Ionic Forum - Latest posts
Viewing all articles
Browse latest Browse all 228595

Single column phone, double tablet

$
0
0

For anyone who is interested, I solved this in the following way:

I had 2 ng-repeats, 1 for the rows and 1 for the items making up the rows.

On my controller I have a function which breaks the original input array (all the items) into rows with items in each row:

$scope.breakIntoRows = function(array, columns) {
var rowArray = [];
for (var i=0; i<array.length; i+=columns) {
rowArray.push(array.slice(i, i+columns));
}
return rowArray;
}

Then I call the function when I get the data back from my factory:

$scope.rows = $scope.breakIntoRows(result.videos, 2);

Then on the view it looks as follows:

<div class="row responsive-md" ng-repeat="row in rows">
<div class="col" ng-repeat="item in row">
<!-- Do whatever you need to do here -->

Hope this helps someone :smile:


Viewing all articles
Browse latest Browse all 228595

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>