2 Demos of Angular side menu with Bootstrap navbar

Creating the sidebar with Angular and Bootstrap navbar

The ng-bs-navbar is an Angular directive that can be used for creating the navbar based on Bootstrap, as well as it includes a handy sidebar.

You may also place the icons from the materialIcon with the menu items.

Developer page Download plug-in

How to setup this Angular directive?

You need to setup the routes with navbar in the JS code where you may also set the icons. See the navbar.js and ng-bs-navbar.js files that download with the zipped file.

Include the dependency files:

<script type=”text/javascript” src=”bower_components/ng-bs-navbar/dist/ng-bs-navbar.js”></script>
<link rel=”stylesheet” href=”bower_components/ng-bs-navbar/dist/ng-bs-navbar.css” type=”text/css” />
<link rel=”stylesheet” href=”bower_components/ng-bs-navbar/dist/ng-bs-navbar-theme-dark.css” type=”text/css” />
<link href=”https://fonts.googleapis.com/icon?family=Material+Icons” rel=”stylesheet”>

See the demo and code below for learning how to use the code.

A demo with dark theme

In this demo, the dark theme is used for the menus. You can see the position heading with two buttons. Upon pressing the top, the position of the left menu will change to the top. Similarly, you may use the Condensed or Full view of the menu by pressing the respective button:

Angular sidebar

See the online demo and code

Code:

<!doctype html>
<html ng-app="ng-bs-navbar-example">
<head>
    <meta charset="utf-8">
    <link href="https://fonts.googleapis.com/icon?family=Material+Icons"
          rel="stylesheet">
    <link rel="stylesheet" href="https://netdna.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">

    <link rel="stylesheet" href="css/ang-navbar/ng-bs-navbar.css" type="text/css" />
    <link rel="stylesheet" href="css/ang-navbar/ng-bs-navbar-theme-dark.css" type="text/css" />

    <link rel="stylesheet" href="css/ang-navbar/example.css" type="text/css" />

  
</head>
<body>
  <body>

  <navbar position="left"></navbar>

  <div class="main" ng-controller="ExampleController">
    <h1>ng-bs-navbar example</h1>

    <p>Examples on how to interactive with the navbar</p>

    <h4>Position</h4>
    <pre></pre>
    <div class="btn-group">
      <a class="btn btn-primary" ng-click="position = 'left'">Left</a>
      <a class="btn btn-primary" ng-click="position = 'top'">Top</a>
    </div>

    <h4>Size (left only)</h4>

    <p>Setting for the navbar when positioned to the left <i>and right in the future</i></p>
    <pre></pre>
    <div class="btn-group">
      <a class="btn btn-primary" ng-click="size = 'condensed'">Condensed</a>
      <a class="btn btn-primary" ng-click="size = 'full'">Full</a>
    </div>

    <h3>Current Controller</h3>
    <div class="well" ng-view></div>
  </div>

  <script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.0-beta.1/angular.min.js"></script>
  <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.0-rc.0/angular-route.min.js"></script>
  <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/angular-ui-bootstrap/0.14.3/ui-bootstrap.min.js"></script>

  <script type="text/javascript" src="js/ang-navbar/ng-bs-navbar.js"></script>
  <script type="text/javascript" src="js/ang-navbar/navbar.js"></script>
</body>
</html>


A demo of light color theme

For the above demo, the ng-bs-navbar-theme-dark.css file was used for creating the darkish theme. You may customize that file or add your own style to match the theme of left or top navigation bar with the rest of the website design.

For this demo, the ng-bs-navbar-theme-dark.css is removed and the light color scheme is used as follows:

Angular top bar

See online demo and code

Learn more about this directive here.