1

In child component ngOnChanges() is called twice for each array element.

this is my category.html

<ng-template ngFor let-fourlet [ngForOf]="productFourlets()" let-i="index">
    <div class="row" > 
        <pdp-product-list-item *ngFor="let product of fourlet" 
                                [product]="product" 
                                [category]="category" 
                                class="col-xs-12 col-sm-3 col-md-3 col-lg-3  product-item">
        </pdp-product-list-item>
    </div>
  </ng-template>

productFourlets() is function that returns array of arrays. Example here Angular 2 *ngFor - Conditional wrapper element. Like using bootstap row with three columns inside, then add a new row

So something is really off here in pdp-product-list-item component elements are received via @Input() and then half a second pause and the same elements arrive again.

This causes all kind of problems in child component

Anyone experienced this ?

SeaBiscuit
  • 2,553
  • 4
  • 25
  • 40
  • 3
    Do not call methods in template, all kinds of weird stuff happens :P https://stackoverflow.com/questions/37876533/ngfor-running-an-infinite-loop-in-angular2 – AT82 Oct 28 '17 at 18:40
  • that was it.. write it as answer so i can accept – SeaBiscuit Oct 28 '17 at 18:43
  • I'll mark it as a duplicate instead, as the answer in the linked answer solves your issue. But glad to hear we got to the root problem quickly! :) – AT82 Oct 28 '17 at 18:47

0 Answers0