Quantcast
Channel: Ionic Forum - Latest topics
Viewing all articles
Browse latest Browse all 70612

Ion-list not updating when items change

$
0
0

@kpesanka wrote:

Hi! I'm having an odd problem that only seemed to surface when I began using Ionic2 with Angular2 (as opposed to originally just using Angular2).

I have a Page that contains an ion-list, and I do an ngFor to loop through and create the ion-items. The relevant HTML:

<ion-list>
    <ion-item *ngFor="#unit of units">
    {{unit.description}}
    </ion-item>
  </ion-list>

In my Page, the constructor sets its units property to be the units property of an injected service:

export class UnitsPage {

    units: Unit[] = [];

    constructor(unitService: UnitService) {
        this.units = unitService.units;
    }

The injected unitService takes a little while to get its units, so at the time the constructor fires, this.units is still an empty array. When it finally gets populated, the ion-list does not update. If I put the 'this.units' assignment inside a setTimeout, it works just fine. It's almost as if one-time binding is going on here.

Thoughts?

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 70612

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>