How to show and hide UI elements based on User Role

1,615 views
Skip to first unread message

Ashit Vora

unread,
Jul 11, 2013, 12:24:11 AM7/11/13
to ang...@googlegroups.com
Hi,

This is more of a architecture question.
I've an app with two types of users - Admin and Staff.
I want to show hide certain UI components based on user's role.

what's the best way to do that.

One way I was thinking is once the app is bootstraped, I get User's info and store it in rootscope and the use it always to show/hide UI components.

Is this the right approach?

Peter Bacon Darwin

unread,
Jul 13, 2013, 5:29:03 AM7/13/13
to ang...@googlegroups.com

Yes or create a directive that does it for you

Pete
...from my mobile.

--
You received this message because you are subscribed to the Google Groups "AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to angular+u...@googlegroups.com.
To post to this group, send email to ang...@googlegroups.com.
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Ashit Vora

unread,
Jul 13, 2013, 5:34:46 AM7/13/13
to ang...@googlegroups.com
Thanks Pete.

Btw, do you have any link handy (some blog article) that explains this scenario?


-Ashit


--
You received this message because you are subscribed to a topic in the Google Groups "AngularJS" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/angular/W5xI9fiL7qU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to angular+u...@googlegroups.com.

Sebastian Sebald

unread,
Jul 13, 2013, 6:03:58 AM7/13/13
to ang...@googlegroups.com
https://github.com/angular-app/angular-app/blob/master/client/src/common/security/authorization.js

Angular-app uses something similar for routing. But it is essentially the same. Make a service that you can ask for the user role and return a bool. This function can then be used inside an ng-show/hide

Grant Rettke

unread,
Jul 13, 2013, 11:00:38 AM7/13/13
to ang...@googlegroups.com
On Wed, Jul 10, 2013 at 11:24 PM, Ashit Vora <a.k....@gmail.com> wrote:
> Is this the right approach?

Yes, one right approach. We went even simpler and limit it to page.
Reply all
Reply to author
Forward
0 new messages