Quantcast
Channel: Ionic Framework - Ionic Forum
Viewing all articles
Browse latest Browse all 48981

Launch modal from a service right after app start

$
0
0

Hey guys,

I have a quite straight forward app-setup built from the ionic blank starter (Ionic 5). I want to show some onboarding-screens to the users if they start the app for the first time or haven’t provided some relevant information yet which is needed by the app.
I have a central service which checks on the user data and makes the decision if the onboarding is needed after app start or not. This service is injected in the app component, so it’s launched right at app start. It should then launch the modal for the onboarding.

Now I have a strange behavior. When the user must login, everything is fine with the onboarding. When there is no login necessary because there is a valid auth token stored in a cookie, I got the error message “Can’t bind to ‘ngIf’ since it isn’t a known property of ‘div’”. After some research I found out that this error message probably means that the module of the onboarding modal component hasn’t loaded yet. That would explain why it doesn’t show up in login case (modules have enough time to load). I’m using lazy loading with preloadingStrategy: PreloadAllModules, as it is the default.

So the question now: Is there a way to check/wait for a specific module to be loaded? I don’t know if it’s possible to just make that one module not lazy loaded, but it would somehow also feel wrong because in 99% of the times the onboarding screens are not shown, so the lazy loading definetly makes sense here.
Do you have other ideas / design patterns how to achieve what I want?
My current workaround options which don’t feel very well are setTimeout to wait some time before the modal is shown (won’t do that) and launching the modal not from the service but from the page which is shown after app start. That would be okay if there is no clean option available, but it somehow doesn’t feel right as the logic doesn’t belong there.

Regards,
Jonas

1 post - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 48981

Trending Articles