I am trying to create a grid of three cards per row using ng-repeat. I have a normal array of javascript objects attached to the scope. The code below will create a fresh row for every card.
<div layout="row" ng-repeat='post in posts' layout-fill="" layout-align="">
<md-card>
<md-card-content>
<h2 class="md-title">{{post.title}}</h2>
<p>
{{post.summary}}
</p>
</md-card-content>
<div class="md-actions" layout="row" layout-align="end center">
<md-button>View More</md-button>
</div>
</md-card>
<br>
How can I iterate over my array and display the cards in rows of three? I looked at this post and this post but I do not see how they apply to angular material
To be compling to material/angular, you must use flex attr to md-card. Flex attr will give you a proportional width about its parent.
In this example, you will have two cards (40% each) and when the screen resizes to -sm, the cards will be at 80%.
I just needed this; here's a more comprehensive solution, only using the layout features, for 3 columns:
The card must be wrapped inside a correctly-sized div to keep the margins under control and avoid overflow.
I have created something similar to what you may want. The
md-card
is wrapped within adiv
havinglayout-wrap
. The divs are dynamically generated after reading.Here is the code :
The cards width can be adjusted with inline styling, hope it helps.