我使用Angular Material创建了一个工具栏.但是,它没有响应.如何使工具栏响应?
工具栏代码:
<md-toolbar color = "primary"> <button md-button class="md-primary" [routerLink]="['/basic']"><md-icon class = "icon-20">home</md-icon> Angular Concepts</button> <button md-button [mdMenuTriggerFor]="bMenu">Basic Concepts</button> <md-menu #bMenu="mdMenu"> <button md-menu-item [routerLink]="['/a4']">Angular Component</button> <button md-menu-item [routerLink]="['/cli ']">Angular CLI</button> <button md-menu-item [routerLink]="['/inout']">Event Emitters</button> <button md-menu-item [routerLink]="['/template']">Template Driven Forms</button> <button md-menu-item [routerLink]="['/reactive']">Data Driven Forms</button> <button md-menu-item [routerLink]="['/directives']">Angular Custom Directives</button> <button md-menu-item [routerLink]="['/pipes']">Custom Pipes</button> <button md-menu-item [routerLink]="['/viewchild']">View Child</button> <button md-menu-item [routerLink]="['/view']">View Encapsulation</button> </md-menu> <button md-button [mdMenuTriggerFor]="aMenu">Advanced Concepts</button> <md-menu #aMenu="mdMenu"> <button md-menu-item [routerLink]="['/ngrx']">Angular Redux using ngrx/store</button> <button md-menu-item [routerLink]="['/guard']">Angular Guards</button> <button md-menu-item [routerLink]="['/host']">Host & Host-Context</button> </md-menu> <button md-button (click)="openDialog()"> Contact Card</button> </md-toolbar>
问题
您需要一种方法来使您的导航栏响应.
解
您可以将Material Angular与ToolBar和Flex-Layout一起使用.
例
npm install @angular/flex-layout --save
具有Flex布局的示例角度材质工具栏.这是一个很棒的教程@L_301_3@.
<div style="height: 100vh;"> <mat-toolbar color="primary"> <span>Responsive Navigation</span> <span class="example-spacer"></span> <div fxShow="true" fxHide.lt-md="true"> <!-- The following menu items will be hidden on both SM and XS screen sizes --> <a href="#" mat-button>Menu Item 1</a> <a href="#" mat-button>Menu Item 2</a> <a href="#" mat-button>Menu Item 3</a> <a href="#" mat-button>Menu Item 4</a> <a href="#" mat-button>Menu Item 5</a> <a href="#" mat-button>Menu Item 6</a> </div> <div fxShow="true" fxHide.gt-sm="true"> <a href="#" (click)="sidenav.toggle()">Show Side Menu</a> </div> </mat-toolbar> <mat-sidenav-container fxFlexFill class="example-container"> <mat-sidenav #sidenav fxLayout="column"> <div fxLayout="column"> <a (click)="sidenav.toggle()" href="#" mat-button>Close</a> <a href="#" mat-button>Menu Item 1</a> <a href="#" mat-button>Menu Item 2</a> <a href="#" mat-button>Menu Item 3</a> <a href="#" mat-button>Menu Item 4</a> <a href="#" mat-button>Menu Item 5</a> <a href="#" mat-button>Menu Item 6</a> </div> </mat-sidenav> <mat-sidenav-content fxFlexFill>Main content</mat-sidenav-content> </mat-sidenav-container> </div>