码迷,mamicode.com
首页 > 编程语言 > 详细

Material使用09 MdMenuModule

时间:2017-12-27 15:37:22      阅读:177      评论:0      收藏:0      [点我收藏+]

标签:provider   bubuko   opened   primary   inf   按钮   inpu   mon   image   

1 md-menu

  是一个浮动型的选择面板,它必须依赖一个触发组件(按钮、单击等)

 

2 md-menu的使用

  2.1 在共享模块中引入MdMenuModule

    技术分享图片

技术分享图片
import { NgModule } from ‘@angular/core‘;
import { CommonModule } from ‘@angular/common‘;
import { 
  MdSidenavModule, 
  MdToolbarModule,
  MdIconModule,
  MdButtonModule,
  MdIconRegistry,
  MdCardModule,
  MdInputModule,
  MdListModule,
  MdSlideToggleModule,
  MdGridListModule,
  MdDialogModule,
  MdAutocompleteModule,
  MdMenuModule
 } from ‘@angular/material‘;
 import { HttpModule } from ‘@angular/http‘;

@NgModule({
  imports: [
    CommonModule,
    HttpModule,
    MdSidenavModule,
    MdToolbarModule,
    MdIconModule,
    MdButtonModule,
    MdCardModule,
    MdInputModule,
    MdListModule,
    MdSlideToggleModule,
    MdGridListModule,
    MdDialogModule,
    MdAutocompleteModule,
    MdMenuModule
  ],
  declarations: [],
  exports: [
    CommonModule,
    MdSidenavModule,
    MdToolbarModule,
    MdIconModule,
    MdButtonModule,
    HttpModule,
    MdCardModule,
    MdInputModule,
    MdListModule,
    MdSlideToggleModule,
    MdGridListModule,
    MdDialogModule,
    MdAutocompleteModule,
    MdMenuModule
  ],
  providers: [
    // MdDialog
  ]
})
export class SharedModule { }
View Code

  2.2 在组件中使用md-menu组件

    技术分享图片

技术分享图片
<h3>GridList</h3>
<div class="box">
  <md-grid-list cols="4">
    <md-grid-tile>
      <md-grid-tile-header>页眉</md-grid-tile-header>
      <md-icon>menu</md-icon>测试01
      <md-grid-tile-footer>页脚</md-grid-tile-footer>
    </md-grid-tile> 
  </md-grid-list>
</div>
<hr />

<h3>Dialog</h3>
<div class="box">
  <button class="fab-button" md-fab type="button" (click)="openNewProjectDialog()" color="primary">
      <md-icon>add</md-icon>
  </button>
</div>

<h3>Menu</h3>
<div class="box">
  <button class="fab-button" md-fab type="button"  color="accent" [mdMenuTriggerFor]="testMenu">
      <md-icon>menu</md-icon>
  </button>
  <md-menu #testMenu="mdMenu">
    <button md-menu-item (click)="onClick(‘刷新按钮‘)">
      <md-icon>autorenew</md-icon>
      <span>刷新</span>
    </button>
    <button md-menu-item (click)="onClick(‘设置按钮‘)">
      <md-icon>settings</md-icon>
      <span>设置</span>
    </button>
  </md-menu>
</div>


<!-- <md-grid-list cols="4" rowHeight="1:1" gutterSize="1px">
  <md-grid-tile colspan="2">测试01:跨两行</md-grid-tile>
  <md-grid-tile rowspan="2">测试02:跨两列</md-grid-tile>
  <md-grid-tile>测试03</md-grid-tile>
  <md-grid-tile colspan="2" rowspan="2">测试04:跨两行,跨两列</md-grid-tile>
  <md-grid-tile>测试05</md-grid-tile>
  <md-grid-tile>测试06</md-grid-tile>
  <md-grid-tile>测试07</md-grid-tile>
</md-grid-list> -->
View Code

  2.3 效果展示

    技术分享图片

 

Material使用09 MdMenuModule

标签:provider   bubuko   opened   primary   inf   按钮   inpu   mon   image   

原文地址:https://www.cnblogs.com/NeverCtrl-C/p/8125932.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!