11 thoughts on “Ionic 5|4 Login & Registration Form using Guard Working UI Example Application”

  1. The big issue with this approach (that is the same that i saw in many others tutorials, btw) is that authguard check BEFORE that autentication service even be created, so if you refresh the page the first thing you say is app root (whatever it is, in my case login page) and only AFTER will subscribe for changing in authState (that will be fired in constructor service itself). Basically, login page appears for 1 sec or so. And i don’t like it.

  2. Thank you for nice article. This example working fine.

    But, How I can handle hardware back button on login page after user logged in, both in sidebar and tabs page application. In device after login success tabs page comes than after press back button than login page show again 🙁

    I tried to add a new authGaurd for login page, but blank page comes for few sec.

    How can handle this? Please post a example.


    1. instead of




      to do this you have to import NavController first:

      import { NavController } from ‘@ionic/angular’;

      and in your constructor:

      constructor(private navCtrl: NavController)

  3. Thank you. But there’s an error. Why is that? I did the same thing.
    Error: StaticInjectorError(AppModule)[AuthGuardService -> AuthenticationService]:
    StaticInjectorError(Platform: core)[AuthGuardService -> AuthenticationService]:
    NullInjectorError: No provider for AuthenticationService!

  4. Thanks, nice simple explanation.
    How would you handle different access Levels? e.g. in WordPress you have Admin, Authors etc.

    Say I have Level 1, Level 2, Level 3 users how would I save, and use their access level using this technique?

Leave a Comment

Your email address will not be published. Required fields are marked *