0

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.

1 Answer 1

1

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>
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.