0
我在我的應用程序中有4頁。 LoginPage,TransistionPage,FirmsPage和ReportsPage。 如果用戶已經過身份驗證,我的根頁面是TransistionPage,此頁面僅負責從休息中獲取數據並將其傳遞給FirmsPage。nav.popToRoot()顯示空白屏幕
我試圖從navi.popToRoot()返回到ReportsPage的根頁面(讓我們假設用戶已經通過身份驗證並且根頁面是TransistionPage),但是當我這樣做時,我只是面對着白色的空白頁面。
//報告頁面
@Component({
selector: 'page-report',
templateUrl: 'report.html'
})
export class ReportsPage {
sales: any[];
collectings: any[];
summary: any[];
products: any[];
loading: any;
firmId: string;
constructor() {}
goBack(){
this.navCtrl.pop();
}
}
// Transistion頁
@Component({
selector: 'page-transistion-page',
templateUrl: 'transistion-page.html'
})
export class TransistionPage {
firms: any;
loading: any;
constructor(public navCtrl: NavController, private navParams: NavParams, public loadingCtrl: LoadingController, public firmService: FirmService) {
this.getFirms();
}
ionViewDidLoad() {
console.log('Hello TransistionPage Page');
}
getFirms(){
this.presentLoading();
this.firmService.getFirms()
.subscribe(
data => {
this.firms = data.subeler;
//this.loading.dismiss();
this.navCtrl.push(FirmsPage,{param: this.firms},{animate: true, direction: 'back'});
},
error => alert(error),
() => console.log("firmalar çekildi")
);
}
presentLoading() {
this.loading = this.loadingCtrl.create({
content: "Welcome "+window.localStorage.getItem('username')+ " , directing to the firms page",
duration: 1000,
dismissOnPageChange: false
});
this.loading.present();
}
}
//公司網頁
@Component({
selector: 'page-firms',
templateUrl: 'firms.html'
})
export class FirmsPage {
langs;
langForm;
loading: any;
username : string;
firms: any;
constructor(public navCtrl: NavController, private navParams: NavParams, public firmService: FirmService, public loadingCtrl: LoadingController, public authService: Auth) {
this.firms = this.navParams.get('param');
this.username = window.localStorage.getItem('username');
this.langForm = new FormGroup({
"langs": new FormControl('')
});
}
ionViewDidLoad() {
console.log('Hello FirmsPage');
}
doSubmit() {
console.log('Submitting form', this.langForm.value.langs);
this.navCtrl.push(ReportsPage, {param:this.langForm.value.langs},{animate: true, direction: 'back'});
}
logout(): void {
this.authService.logout();
this.navCtrl.setRoot(LoginPage);
}
}
通常情況下,請求工作。但是,當我popToRoot頁面不加載時,我認爲,它可以與我做請求的地方相關聯。我是在構造函數中完成的。這就是爲什麼當popToRoot時頁面不能請求。如果這是問題。我在哪裏可以要求?
你聲明'公共navCtrl:在報告頁面NavController'?還是隻是在你的snipet失蹤? – Huiting