Ok I will try, Thank you :) On Monday, January 20, 2014 12:50:12 PM UTC+5:30, Steve Lorimer wrote: > > ng-show is an attribute directive on an html element. You specify a > javascript expression in the attributes value. Angular will evaluate the > expression in terms of the current controller's $scope, and if the result > is truthy, then that html element will be shown in your page. If it is > falsey then it won't. > > So for my previous example, I've got a menu (unordered list) which has > several entries (list items). One such menu entry is a list item with a > link called "Admin", and location "/admin". > > <li><a href="/admin">Admin</a></li> > > Now we want to selectively display this item. > > We have a function in our controller's $scope called isAdmin. The return > value will be true if the current logged in user's role is "admin". > > So we use the ng-show attribute directive, with the value being the > expression "isAdmin()". > > <li *ng-show="isAdmin()"*><a href="/admin">Admin</a></li> > > > If you want to browse through a working example which does something > similar then check out the angular fullstack generator. It uses a similar > concept for showing menu items based on whether a user is logged in or not. > See here: > https://github.com/DaftMonk/fullstack-demo/blob/master/app/views/partials/navbar.html#L6 > > When the user logs in, the current user is saved on the root scope ( > https://github.com/DaftMonk/fullstack-demo/blob/master/app/scripts/services/auth.js#L26 > ) > > > As an aside, I would highly recommend watching the egghead.io series to > gain a deeper understanding of angular et al: http://egghead.io/lessons >
-- 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 [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/angular. For more options, visit https://groups.google.com/groups/opt_out.
