How to Show/Hide Elements Based on User Roles with Ionic [v4]

ionic-4-role-based-elements-header

When you build an authentication system for your app it’s very likely that you also have some sort of role management. If you want to show or hide different elements in your Ionic app based on a role, this is for your.

In this Quick Win we will use a dummy auth service (so no real backend) but a real directive that will accept a role as input and automatically checks if the user has the role and display the component then.

ionic-4-role-auth

We will have a user and admin, and we’ll also quickly add some animations but let me know below if you’d like to see more content on animations!


The full quick win with snippets is only available to Ionic Academy members.
Join now for

  • Unlimited access to all quick wins
  • Library of 40+ step-by-step video courses
  • Support for Ionic questions via Slack & private community

Join now & Unlock

Current member? LOGIN


Leave a Reply

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