Angular auto open/close row div?

Hello,

I have a question, I display two cards on the same row, and I would like that with each double iteration, it closes the div of the previous row to display a new one.

You have an idea ?

what about a javascript/css solution?