离子2:在离子载玻片内产生ng重复

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

本文关键字:重复 ng 离子      更新时间:2023-09-26

我正在尝试创建一个滑块样式的页面,该页面基于给定的json文件显示动态数据。

在我的控制器中:

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

在我的html:中

 <ion-slides>
    <ion-slide ng-repeat="test in tests">
        {{test.name}}
    </ion-slide>
 </ion-slides>

即使console.log被解雇,页面也不会出现。我猜我的html中有一些语法错误,我没有注意到。我必须在Ionic 2中使用collection repeat吗?

角度2中没有ng-repeat…应该是

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

但我想你可能想看看这个问题,看看它是否会影响到你。

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