0
類型有問題。一切都很好,除了這行代碼:myworkout:屬性不存在
"this.workoutService.deleteWorkout(workoutId).subscribe(data => {
this.result = data;"
具體來說,「workoutService」 ...它說:「物業‘workoutService’不上鍵入‘WorkoutDetailsPage’存在。」
從這個代碼(WorkoutDetailsPage):
import { Component } from '@angular/core';
import { NavController, NavParams } from 'ionic-angular';
import { WorkoutService } from '../../app/services/workout.service';
import { WorkoutsPage } from '../workouts/workouts'
@Component({
selector: 'workout-details',
templateUrl: 'workout-details.html'
})
export class WorkoutDetailsPage {
public workout: any;
public result: any;
constructor(public navCtrl: NavController, public params:NavParams, workoutService:WorkoutService) {
this.workout = params.get('workout');
}
deleteWorkout(workoutId){
this.workoutService.deleteWorkout(workoutId).subscribe(data => {
this.result = data;
});
this.navCtrl.push(WorkoutsPage);
}
}
結果是這樣的: enter image description here
以供將來參考,它可能是最好不要使用圖片代碼片斷。只需將代碼粘貼到StackOverflow編輯器中,突出顯示它,然後單擊代碼按鈕。它使得它對幫助你的人更具可讀性,我們也可以從片段中複製來給出我們的答案。 – spectacularbob