在这里,我有JSONOBJ的结果:在我的Home.html与方法navigate()
它看起来像这样离子2不显示幻灯片时练习做
我有ion-card
:
navigate(event, exercise, exercise2, exercise3, exercise4){
this.navCtrl.push(exerciseSlides, {
clickedExercise: exercise,
secondExercise: exercise2,
thirdExercise: exercise3,
fourthExercise: exercise4
});
}
而这些卡片2:
<ion-card *ngIf="oefening1" (click)="navigate($event, oefening1, oefening2, oefening3, oefening4)" class="{{ oefening1 }}" margin-vertical>
<img src="assets/img/{{ oefening1 }}.jpg"/>
<div *ngIf="exercise1IsDone || allExercisesDone" (click)="$event.stopPropagation()" class="overlay">
<ion-icon name="checkmark-circle" class="checkmark"></ion-icon>
</div>
<ion-card-content>
<ion-card-title>{{ oefening1 }}</ion-card-title>
<p>Setjes: {{ set1 }}</p>
<p>Herhalingen: {{ rep1 }}</p>
</ion-card-content>
</ion-card>
<ion-card *ngIf="oefening2" (click)="navigate($event, oefening2, oefening1, oefening3, oefening4)" class="{{ oefening2 }}" margin-vertical>
<img src="assets/img/{{ oefening2 }}.jpg"/>
<div *ngIf="exercise2IsDone || allExercisesDone" (click)="$event.stopPropagation()" class="overlay">
<ion-icon name="checkmark-circle" class="checkmark"></ion-icon>
</div>
<ion-card-content>
<ion-card-title>{{ oefening2 }}</ion-card-title>
<p>Setjes: {{ set2 }}</p>
<p>Herhalingen: {{ rep2 }}</p>
</ion-card-content>
</ion-card>
我有一个exerciseSlides.html这样的:
<ion-content>
<ion-slides #exercisesSlider>
<ion-slide *ngFor="let ex of allExercises; let i = index" id="{{ ex.exercise }}">
<ion-grid>
<ion-row>
<ion-col col-12>
<div (click)="playVid(ex.exercise)" padding-bottom>
<img [src]="ex.path" />
</div>
<div text-center>
<!-- can't go back if it's the first exercise -->
<button *ngIf="i > 0" ion-button round (click)="previousExercise()">Vorige</button>
<!--<button ion-button block [disabled]="!disabledBtn">Block Button</button>-->
<!-- will not have a next exercise if it's the last one -->
<button *ngIf="i < 4" ion-button round (click)="nextExercise(i, ex.exercise, ex.done)">Voltooi</button>
{{ ex.done }}
</div>
</ion-col>
</ion-row>
</ion-grid>
</ion-slide>
</ion-slides>
</ion-content>
而一个exerciseSlides.ts这样的:
export class exerciseSlides {
@ViewChild('exercisesSlider') slides: Slides;
public fullPath: string;
public disabledBtn: boolean;
public allExercises: any[] = []; // INITIALIZE A VAR THAT'LL HOLD ALL EXERCISES
public date: any = moment().format('L');
constructor(public navCtrl: NavController, private streamingMedia: StreamingMedia, public params: NavParams, public modalCtrl: ModalController) {
// GET ALL EXERCISES AND THE IMAGE PATH ON PAGE CONSTRUCRION
this.allExercises.push({
exercise: params.get("clickedExercise"),
path: 'assets/img/' + params.get("clickedExercise") + '.jpg',
done: false
});
this.allExercises.push({
exercise: params.get("secondExercise"),
path: 'assets/img/' + params.get("secondExercise") + '.jpg',
done: false
});
this.allExercises.push({
exercise: params.get("thirdExercise"),
path: 'assets/img/' + params.get("thirdExercise") + '.jpg',
done: null
});
this.allExercises.push({
exercise: params.get("fourthExercise"),
path: 'assets/img/' + params.get("fourthExercise") + '.jpg',
done: null
});
this.disabledBtn = false;
}
ionViewDidEnter() {
// block the swipe to change page
this.slides.lockSwipes(true);
}
nextExercise(i, id, done) {
this.slides.lockSwipes(false);
this.slides.slideNext();
this.slides.lockSwipes(true);
//Here is set the done value of opened slide to true, but gets overrided by the constructor.
this.allExercises[i].done = true;
console.log(this.allExercises[i].done);
if (this.allExercises[i].exercise == 'lagerugklacht'){
console.log('check', this.allExercises[i]);
localForage.setItem('exercise1IsDone', [this.allExercises[i].exercise, this.allExercises[i].done]);
console.log('localForageItem: ', localForage.getItem("exercise1IsDone"));
}
let modal = this.modalCtrl.create(ModalPage);
modal.present();
if(i == 3){
console.log("lastOne");
this.navCtrl.push(HomePage);
localForage.setItem('didAllExercises', [true, this.date]);
}
}
}
如何设置的this.allExercises[i].done
到真正的价值,创造一个*ngIf
检查,如果运动做,而当其做得比不显示再滑?
的allExercises.done
总是首先进入到假的,因为我设置的是,在构造函数中我发出后nextExercise()
,但我怎样才能改变allExercises.done
的poperty到真正的数组中,并保持忠于它的变化?所以如果它完成了,它必须跳过那张幻灯片,然后继续下一个没有完成的幻灯片。
你可以发布一个锻炼的结构?它是一个对象吗?它来自服务器吗?你如何得到锻炼? –
它是来自mysql服务器的json对象。看起来像这样: '{“OEFENING1”:'lagerugklacht',“OEFENING2”:'nekklacht',“OEFENING3”:null,“OEFENING4”:null,“GOALS”:null}' – Sreinieren
@GabrielBarreto我加了一个我的console.log图片 – Sreinieren