2

我想在点击民意调查时,打开下拉菜单,其中包括子类别的拉动。

在此处输入图像描述

我应该如何更改我的代码以便通过材料设计添加此功能。

在状态提供者中:

 $stateProvider
       .state('admin', {
        /*abstract: true,*/
        url: '/admin',
        templateUrl: 'app/admin/admin.html',
        controller: 'AdminCtrl',
        onEnter: function($rootScope) {
        $rootScope.title = $rootScope.titleRoot + ' | Admin';
        }
      });
  });

在 .html 中

<md-sidenav class="md-sidenav-left md-whiteframe-z2" md-component-id="left" md-is-locked-open="$mdMedia('gt-md')">
    <md-toolbar class="md-theme-indigo">
      <h1 class="md-toolbar-tools">Admin</h1>
    </md-toolbar>
    <md-content class="" ng-controller="LeftCtrl">
      <md-button ng-click="close()" class="md-primary" hide-gt-md>
        Close Sidenav Left
      </md-button>
      <!--<p hide-md show-gt-md>-->
      <!--</p>-->
      <ul class="sidenav-menu">
        <li class="" ng-repeat="section in sections">

          <md-button ui-sref="{{section.link}}">
            <i class="fa fa-fw {{section.icon}}"></i> {{section.title}}
          </md-button>

        </li>
      </ul>
    </md-content>
  </md-sidenav>

内部控制器:

.controller('AdminCtrl', function($scope, $mdSidenav, $timeout, $log) {
    $scope.sections = [
      {
        title: 'User Management',
        icon: 'fa-user',
        link: 'usermanagement'
      },{
        title: 'Polls',
        icon: 'fa-files-o',
        link: 'polls'
      }    
    ];    
    $scope.toggleLeft = function () {
      $mdSidenav('left').toggle()
        .then(function () {
          //$log.debug("toggle left is done");
        });
    };
  })
  .controller('LeftCtrl', function($scope, $timeout, $mdSidenav, $log) {
    $scope.close = function() {
      $mdSidenav('left').close()
        .then(function(){
          //$log.debug("close LEFT is done");
        });
    };
  });
4

1 回答 1

-1

由于您使用的是 Angular-Material,我建议您使用它的菜单指令:https ://material.angularjs.org/latest/#/demo/material.components.menu

于 2015-07-21T19:47:04.833 回答