I am struggling to dynamically change the number of columns in a row based on the already sorted array. I want the layout to look like the example at the bottom, with Comedies spanning two rows, Action spanning three, and Horror only one row. However, I can't seem to figure out how to achieve this using Typescript.
var movies = [
{ title: 'movie 1', genre: 'comedy' },
{ title: 'movie 2', genre: 'comedy' },
{ title: 'movie 3', genre: 'action' },
{ title: 'movie 4', genre: 'action' },
{ title: 'movie 5', genre: 'action' },
{ title: 'movie 6', genre: 'horror' }
];
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css">
<!-- jQuery library -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<!-- Popper JS -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script>
<!-- Latest compiled JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js"></script>
<div *ngFor="let movie of movies; let index = index">
<div class="form-row">
<div class="col">{{movie.title}}</div>
</div>
</div>
<div class="form-row">
<div class="col-3">Movie 1</div>
<div class="col-3">Movie 2</div>
<div class="col-3">Movie 3</div>
</div>
<div class="form-row">
<div class="col-6">Movie 4</div>
<div class="col-6">Movie 5</div>
</div>
<div class="form-row">
<div class="col-3">Movie 6</div>
</div>