我希望传递一个对象数组,并按照pasillo的顺序将其排列到下一页,在离子列表1中使用pasillo 1的对象依此类推。我有点新的离子2,我无法想象如何,我试图用ng-hide制作但没有运气,如果你可以帮助我,我会更感谢。我现在得到的错误是未定义的listaRdy [i] .pasillo。 listaRdy {名称:字符串,pasillo:号码,ID:字符串}
typescript文件:
import { Component } from '@angular/core';
import {IonicPage, NavController, NavParams} from 'ionic-angular';
@IonicPage()
@Component({
selector: 'page-lista-ready',
templateUrl: 'lista-ready.html',
})
export class ListaReadyPage {
listaRdy:{name:string,pasillo:number,id:string}[];
pasillo1=false;
pasillo2=false;
pasillo3=false;
pasillo4=false;
pasillo5=false;
pasillo6=false;
pasillo7=false;
pasillo8=false;
pasillo9=false;
pasillo10=false;
pasillo11=false;
pasillo12=false;
pasillo13=false;
pasillo14=false;
constructor(public navCtrl: NavController, public navParams: NavParams) {
this.listaRdy=this.navParams.data;
}
ionViewWillEnter(){
for(var i=0; this.listaRdy.length;i++) {
if (this.listaRdy[i].pasillo == 1) {
this.pasillo1 = true;
}
if (this.listaRdy[i].pasillo == 2) {
this.pasillo2 = true;
}
if (this.listaRdy[i].pasillo == 3) {
this.pasillo3 = true;
}
if (this.listaRdy[i].pasillo == 4) {
this.pasillo4 = true;
}
if (this.listaRdy[i].pasillo == 5) {
this.pasillo5 = true;
}
if (this.listaRdy[i].pasillo == 6) {
this.pasillo6 = true;
}
if (this.listaRdy[i].pasillo == 7) {
this.pasillo7 = true;
}
if (this.listaRdy[i].pasillo == 8) {
this.pasillo8 = true;
}
if (this.listaRdy[i].pasillo == 9) {
this.pasillo9 = true;
}
if (this.listaRdy[i].pasillo == 10) {
this.pasillo10 = true;
}
if (this.listaRdy[i].pasillo == 11) {
this.pasillo11 = true;
}
if (this.listaRdy[i].pasillo == 12) {
this.pasillo12 = true;
}
if (this.listaRdy[i].pasillo == 13) {
this.pasillo13 = true;
}
if (this.listaRdy[i].pasillo == 14) {
this.pasillo14 = true;
}
}
}
}
HTMLFILE:
<ion-header>
<ion-navbar>
<ion-title>listaReady</ion-title>
</ion-navbar>
</ion-header>
<ion-content padding>
<ion-list>
<ion-list-header ng-hide="pasillo1==false" >Pasillo 1</ion-list-header>
</ion-list>
<ion-list>
<ion-list-header ng-hide="pasillo2==false" >Pasillo 2</ion-list-header>
</ion-list>
<ion-list>
<ion-list-header ng-show="pasillo3==true" >Pasillo 3</ion-list-header>
</ion-list>
<ion-list>
<ion-list-header ng-show="pasillo4==true" >Pasillo 4</ion-list-header>
</ion-list>
<ion-list>
<ion-list-header ng-show="pasillo5==true" >Pasillo 5</ion-list-header>
</ion-list>
<ion-list>
<ion-list-header ng-show="pasillo6==true" >Pasillo 6</ion-list-header>
</ion-list>
<ion-list>
<ion-list-header ng-show="pasillo7==true" >Pasillo 7</ion-list-header>
</ion-list>
<ion-list>
<ion-list-header ng-show="pasillo8==true" >Pasillo 8</ion-list-header>
</ion-list>
<ion-list>
<ion-list-header ng-show="pasillo9==true" >Pasillo 9</ion-list-header>
</ion-list>
<ion-list>
<ion-list-header ng-show="pasillo10==true" >Pasillo 10</ion-list-header>
</ion-list>
<ion-list>
<ion-list-header ng-show="pasillo11==true" >Pasillo 11</ion-list-header>
</ion-list>
<ion-list>
<ion-list-header ng-show="pasillo12==true" >Pasillo 12</ion-list-header>
</ion-list>
<ion-list>
<ion-list-header ng-show="pasillo13==true" >Pasillo 13</ion-list-header>
</ion-list>
<ion-list>
<ion-list-header ng-show="pasillo14==true" >Pasillo 14</ion-list-header>
</ion-list>
</ion-content>