简体   繁体   English

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

[英]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. 我正在尝试做一个滑块样式页面,它根据我给出的json文件显示动态数据。

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: 在我的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. 即使您触发console.log,页面也不会出现。 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? 我猜我的html中有一些语法错误我没注意到。我必须在Ionic 2中使用collection-repeat吗?

there is no ng-repeat in angular2... should be 在angular2中没有ng-repeat应该是

<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 https://github.com/driftyco/ionic/issues/6515

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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