6

I am using Angular 4 with the bulma css framework and I am wondering how I can add a new row (or columns class) every third column.

The index variable which prints out 0,1,2 0,1,2 etc. was when I looking at a snippet when using bootstrap.

Noticed some comments on maybe I can use the template syntax but didn't get that to work either.

<div class="columns">
    <div class="column is-one-third" *ngFor="let item of items | async; let index = index">
      <app-item-details [item]='item '></app-item-details>
      {{ index % 3 }}
    <div class="is-clearfix" *ngIf="index % 3 == 0"></div>
  </div>
</div>
4
  • 2
    ng-if = *ngIf Commented Aug 16, 2017 at 13:01
  • 1
    Please provide the expected output in your question, because I don't understand what you mean here. Commented Aug 16, 2017 at 13:07
  • Yea noticed I type that *ngIf wrong, but that is for the bootstrap snippet so didn't expect that to work when using the bulma framework. (it didn't help either) What I need is to wrap my result around a new columns class every third item in loop. Commented Aug 16, 2017 at 13:10
  • Same as here: stackoverflow.com/questions/27211799/… but with using bulma and angular 4 Commented Aug 16, 2017 at 13:11

2 Answers 2

4

change the condition in *ngIf as below.

*ngIf="(index + 1) % 4 == 0"

Plunker example : https://plnkr.co/edit/C0DrgY3Rty33ZRhyML7E?p=preview

Sign up to request clarification or add additional context in comments.

2 Comments

I think the OP wants to add a div after every 3, in your plunker after first iteration, row gets added after every 4. So, I made some tweaks to your plunker :)
howcome plunker just says loading... ?? cant see any of you guys example rendered on the html. Did I miss anything?
2

Below Solution work for me:

<div class="form-group">
    <div class="row">
        <div class="col-xl-4" *ngFor="let item of productimages; let index = index">
            <img [src]="item.image">
        </div>
    </div>
</div>

enter image description here

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.