简体   繁体   中英

ionic 2 : creating a ng-repeat inside ion-slides

I'm trying to do a slider style page which presents dynamic data based on my json file given.

In my controller:

constructor(navController) {
   this.navController = navController;
   this.populateHistory();
}

populateHistory(){
  console.log("populating!");
   var tests = '{[{"name":"jack"},{"name":"john"},{"name":"joe"}]}';
}

In my html:

 <ion-slides>
    <ion-slide ng-repeat="test in tests">

        {{test.name}}

    </ion-slide>
 </ion-slides>

The page doesn't appear even thou the console.log is fired. I'm guessing there is some syntax error in my html which I failed to notice.Do i have to use collection-repeat instead in Ionic 2?

there is no ng-repeat in angular2... should be

<ion-slides *ngIf="tests.length">
  <ion-slide *ngFor="#test of tests">
    <div>
      {{ test.name }}
    </div>
  </ion-slide>
</ion-slides>

but I think you might want to look at this issue to see if it affects you.

https://github.com/driftyco/ionic/issues/6515

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM