getCategories()在生命周期中挂钩ionViewDidEnter():为什么不再次调用该函数?
我的页面1:
ionViewDidEnter() {
this.platform.ready().then(() => {
this.getCategories();
});
}
getCategories() {
const categorieSub = this.categorieService.getCategories().subscribe((categories) => {
this.categorieList = categories;
},
error => {
console.log('error', error);
});
this.subscriptions.push(categorieSub);
}
ngOnDestroy() {
this.subscriptions.forEach((sub) => {
sub.unsubscribe();
});
}
第2页:
createForm() {
if (this.form.valid) {
const data = this.form.value;
const postCategorieSub = this.categorieService.postCategorie(data).subscribe((categories) => {
console.log('categorie added. So go !');
// this.router.navigate(['/tabs/tab1']);
this.navCtrl.navigateForward('/tabs/tab1'); // after redirection data are not loaded on page 1 by getCategories()
},
err => {
console.log('error on createForm(),', err);
});
this.subscriptions.push(postCategorieSub);
}
}