I'm trying to display dynamically created buttons in rows of two and I'm a little unsure how to do so. So far I've got the following working, but it only works on my limited set of 4 buttons. What I want is for it to insert a linebreak after every second button. Here's my code:
HTML:
<div id="departmentButtonsDiv" *ngFor="let department of lstDepartments; let i
= index">
<span *ngIf="department.blnHiddenOnLandingPage == false">
<button pButton type="button" class="departmentButton"
(click)="navigateToDepartment(department.strName)" label=
{{department.strName}}></button>
</span>
<br *ngIf=" i == 3">
</div>
CSS:
.departmentButton {
height: auto;
width: 200px;
margin-bottom: 2px;
}
#departmentButtonsDiv{
position: relative;
top: 10%;
left: 45%;
display: inline;
}
I initially thought that if I set ngIf to check if index is an even number it would do the trick, but some elements are not necessarily being displayed because their boolean values might exclude them meaning the index variable is incremented anyway. Is there any way to do this check on only the buttons that are being rendered, and if so, how would I go about that?
I'm not really a front-end developer so my HTML/CSS is a bit iffy and I've only been working in Angular for about a month so I'm rather inexperienced on that front too. I would appreciate any help or advice in this regard. I'm even open to better ways of doing this because I'm sure this is only one of many ways of doing it.