2

I am trying to build a website in angularjs with google material design. My codepen url is http://codepen.io/milindsaraswala/pen/yJaYpe

Some Code

<md-content class="navBar">
  <!--class="md-padding"-->
  <md-nav-bar md-selected-nav-item="currentNavItem" nav-bar-aria-label="navigation links">
    <md-nav-item md-nav-click="goto('page1')" name="page1">Item-1</md-nav-item>
    <md-nav-item md-nav-click="goto('page2')" name="page2">Item-2</md-nav-item>
    <md-nav-item md-nav-click="goto('page3')" name="page3">Item-3</md-nav-item>
    <md-nav-item md-nav-click="goto('page4')" name="page4">Item-4</md-nav-item>
    <md-nav-item md-nav-click="goto('page5')" name="page5">Item-5</md-nav-item>
    <!-- these require actual routing with ui-router or ng-route, so they won't work in the demo
    <md-nav-item md-nav-sref="app.page4" name="page4">Page Four</md-nav-item>
    <md-nav-item md-nav-href="#page5" name="page5">Page Five</md-nav-item>-->
  </md-nav-bar>
</md-content>

I was looking to making a navigation menu for the website, something like this enter image description here

If somebody can help me, I will be very appreciative. I've been trying for the past 3-4 days but haven't been able to make it.

ghost_dad
  • 1,308
  • 2
  • 12
  • 21
Milind
  • 1,855
  • 5
  • 30
  • 71

2 Answers2

1

To achieve your expected result , i have used ng-hide and ng-show to show the dropdown list

          <md-nav-item md-nav-click="goto('page1')" ng-click="toggle=!toggle" name="page1">Item-1
        <div class="menuDrop" ng-show="item1 = toggle" ng-hide="item1 =!toggle">
          <a href="#">Link 1</a>
          <a href="#">Link 2</a>
          <a href="#">Link 3</a>

        </div>
      </md-nav-item>

JS: $scope.toggle = true;//to control ng-show and ng-hide onclick

Codepen- http://codepen.io/nagasai/pen/RRGPdj

Naga Sai A
  • 10,771
  • 1
  • 21
  • 40
0

You can use Menu for that.

here is the example.

<md-content flex layout="column">
<md-toolbar>
  <div class="md-toolbar-tools">
    <md-menu>
      <md-button aria-label="Open demo menu" class="md-icon-button" ng-click="$mdOpenMenu($event)">
        Navigation Menu
      </md-button>
      <md-menu-content width="6">
        <md-menu-item ng-repeat="item in [1, 2, 3]">
          <md-button ng-click="navigateTo($index)">
            <md-icon md-menu-align-target md-svg-icon="call:no-sim"></md-icon>
            Option {{item}}
          </md-button>
        </md-menu-item>
      </md-menu-content>
    </md-menu>
    <span flex></span>
  </div>
</md-toolbar>
<md-content>
 //Page Content
</md-content>

Here is the working example.http://codepen.io/next1/pen/PzWZJv

It is wokting with key-board as well.

nextt1
  • 3,858
  • 2
  • 18
  • 26
  • Thanks for your effort but it don't looks like menu and menu position should be under the menu header text – Milind Jun 24 '16 at 05:17
  • Well Official Docs calls it `menu`. You can use `md-offset` attribute on `md-menu` to set the desired offset. please refer to offical Docs once. I updated the codepen. So check that out too. – nextt1 Jun 24 '16 at 05:23
  • Yea, I know that official document calls it as menu but it don't looks like menu and that is the reason I came over here to get help from you guys – Milind Jun 24 '16 at 05:25