Reputation: 979
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?
Upvotes: 1
Views: 1898
Reputation: 7646
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();
Upvotes: 4