I have a list of items and a filter menu. I need help to ensure that my filter settings are stored before my list of items would load when I return from the filter menu back to my itemlist.
Currently my app looks like this:
In the filter menu I would set my Ionic storage to store the filter settings:
You see that ionViewWillEnter is not waiting for your promise to resolve before entering the page. It just is a void method. You can try to use ionViewCanEnter instead in your list view. That way NavController is waiting for your ionViewCanEnter method to resolve with a boolean before entering the page.
When it says ionViewCanEnter being a boolean/Promise, does that mean that it waits for my promise to actually resolve or does it simply want to obtain a promise?
I’m not sure. I think it waits for a Promise and checks if the return value from the promise is true. If not, the page is not allowed to be entered and you get back to your previous page. So you could solve it like that:
async ionViewCanEnter() {
try{
this.filterSettings = await this.localDataProv.getFilter();
//perform filtering of items based on filterSettings
return true;
} catch(error) {
return false;
}
}