Fixed width, dynamic number of columns

Is there a way to have a dynamic number of columns with a relatively fixed with in Ionic? Say you have N columns that are approximately 200px each. On an iPhone in portrait, you would be able to show 3 before breaking. On an iPhone in landscape, you would be able to show 5. From the docs, it seems to assume that you either break all columns into rows at a certain width, or you force all columns into a percentage of screen space. But sometimes you might know the column is X width, and want to display as many as possible, and I don’t see a way to do so.

example you have an ng-repeat

<div ng-repeat="..." ng-style="{width: getWidth()}" style="float:left">...</div>

now you can add a calculation in your controller --> get document width and calculate column width.
Or better calculate your width once in a base controller or so and use the variable directly. After that you can listen to the orientationchange- and resize event to reset the width after device swapped from portait to landscape and reverse.

1 Like