-
Notifications
You must be signed in to change notification settings - Fork 13.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Navigating via url to a page where ionViewCanEnter() fails leads to a white screen #11405
Comments
You can, because you can navigate to new page by doing something like that
and in the guard you do something like that First of all, I'm not sure if this should be the right implementation of doing this, I asked it several times on forum and github but I never got a response to it. So this for now is for me the only one solution I know. And for second, FIY there are many many many bugs and problems with LazyLoading NavController and NavGuards and others. Read this bug #11374 and my last to comments from today there. |
It does work! I have already had similar situations where we currently have to use appCtrl.getRootNav().setRoot() instead of navCtrl.setRoot(), is this actually the way it should work or why does it work like this? |
Are you asking if this is by design?? |
I'm asking whether it is by design, don't understand the difference and when to use which one. |
I don't know if it is by design. Why using appCrt instead of navCtr? In our case we have a multi level of navigation. NavCtrl always returns the nearest by the page, so if you are on a SUB SUB SUB SUB page/navigation you are not sure which one you will get back and if it is the right one. |
Hello @MvRemmerden , could you create a minimal repo that we can use to take a look at this issue? Thanks! |
Sure, will do so tonight. |
Another workaround is using setTimeout
|
is there any update on this? How would a typical ionViewCanEnter guard look using this timeout workaround? |
@rayhaanq I use something like this:
You can also move this code to a service if most of your nav guards have the same behaviour (e.g., checking if the user is logged in).
|
Hi, can somebody explain how the Thanks in advance |
@rricamar there's an example in my latest comment, just before yours. |
timeout will be making the navigation asynchronous, return will complete separately to the application navigating to the other page. |
This issue has been automatically identified as an Ionic 3 issue. We recently moved Ionic 3 to its own repository. I am moving this issue to the repository for Ionic 3. Please track this issue over there. If I've made a mistake, and if this issue is still relevant to Ionic 4, please let the Ionic Framework team know! Thank you for using Ionic! |
Issue moved to: ionic-team/ionic-v3#214 |
Ionic version: (check one with "x")
[ ] 1.x
[ ] 2.x
[x] 3.x
I'm submitting a ... (check one with "x")
[x] bug report
[ ] feature request
[ ] support request => Please do not submit support requests here, use one of these channels: https://forum.ionicframework.com/ or http://ionicworldwide.herokuapp.com/
Current behavior:
With the new lazy loading structure and the Deeplinking method, using NavGuards becomes even more important. But when I use IonViewCanEnter(), I can only return false or true and not set the new page to navigate to, if I load the page directly by URL, so the only thing I will be seeing is a blank screen. I have already tried to pass defaultHistory via @IonicPage(), but that is not working as well
Expected behavior:
I should have to able to set the page I would want to navigate to in case the ionViewCanEnter() fails when typing in the url.
Ionic info: (run
ionic info
from a terminal/cmd prompt and paste output below):Cordova CLI: Not installed
Ionic Framework Version: 3.1.0
Ionic CLI Version: 2.2.3
Ionic App Lib Version: 2.2.1
Ionic App Scripts Version: 1.3.5
ios-deploy version: 1.9.1
ios-sim version: 5.0.13
OS: macOS Sierra
Node Version: v6.10.2
Xcode version: Xcode 8.3.1 Build version 8E1000a
The text was updated successfully, but these errors were encountered: