Reputation: 840
I am writing an app and I would like to have dynamic navbar. I created two separate partials with navbar for logged and guest user. In my index.html I created section where the navbar will be.
<div class="navbar navbar-fixed-top" ng-controller="NavbarCtrl">
<div class="navbar-inner">
</div>
<!-- /navbar-inner -->
</div>
Navbar controller should decide with one partial should be rendered. I check there if user is authenticated or not. But I don't know how to render partial from controller. Thanks for all answers and sorry for my english.
Upvotes: 0
Views: 1329
Reputation: 1017
You'll have your logic in your Navbar controller which would assign, say $scope.nav_partial_url
the proper value (partials/navbar.html or partials/navbar_loggedin.html) based on whether the user is logged in or not. In your view you'd use ngInclude:
<div class="navbar navbar-fixed-top" ng-controller="NavbarCtrl">
<div class="navbar-inner">
<div ng-include="nav_partial_url"></div>
</div>
<!-- /navbar-inner -->
</div>
Upvotes: 1