Ionic 2 & collection-repeat

Viewed 6381

I'm making *ngFor working well with Ionic 2 but I'd like to use collection-repeat 'cause it is more adapted to wide range of data.

I'm loading the data in the construtor :

import {Page, NavController, NavParams} from 'ionic-angular';
import {ListData} from './list-data';

@Page({
    templateUrl: 'build/pages/list-browser/list-browser.html',
    providers: [ListData]
})
export class ListBrowserPage {
    static get parameters() {
        return [[NavController], [NavParams], [ListData]]; // ];
    }

    constructor(nav, navParams, listData){
        this.nav = nav;

        this.items =  listData.getItems(); 
        // listData.getItems() returns a 10 000 rows JSON : 
        //  [{
        //      name: 'Al Aporte', address: '201 Thunder Wagon Common, Cataract, RI, 02987-1016, US, (401) 747-0763',
        //      name: 'Jack Adit', address: '5198 Silent Parade, Round Bottom, MD, 21542-9798, US, (301) 060-7245',
        //      ...
        //  }]
    } 
}

Here is my view with *ngFor, there my injected data is working fine :

<ion-list>
  <ion-item *ngFor="#item of items"> 
    {{ item.name }} 
  </ion-item>
</ion-list>

But the same data loaded with collection-repeat doesn't work :

<ion-list>
    <ion-item collection-repeat="item in items">
        {{ item?.name }} 
    </ion-item>
</ion-list>

No data and no errors. I know that this is a lot of data and that I can split my JSON on the server side but that case is for benchmarking purposes (Ionic 1 & collection-repeat is far better than Ionic 2 & ngFor).

Does Ionic 2 beta include that directive ?

Thanks,

Dédé

3 Answers
Related