1

I make dynamic menu based on angular.js

I want show menu two ways. one is before login, other is after login

my menu code is here

navbar.js

$scope.menu = [{
  'title': 'Home',
  'link': '/'
},
{
  'title': 'About',
  'link': '/about'
},
{
  'title': 'Contact',
  'link': '/contact'
},
{
  'title': 'Workspace',
  'link': '/workspace'
},
{
  'title': 'SignIn',
  'link': '/signin'
}
];
...

and my html file is here

  <ul class="nav nav-pills pull-right">
    <li ng-repeat="item in menu" ng-class="{active: isActive(item.link)}">
        <a ng-href="{{item.link}}">{{item.title}}</a>
    </li>
  </ul>

I want add signout menu, and only show after login. how I solve this problem?

1 Answer 1

4

You should generate $scope.menu based on your users status so that it only contains the links you need.

var getAvailableLinks = function () {
    // Generate the links here.
};

$scope.menu = getAvailableLinks();
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.