Angular6 角度6错误:模板分析错误:没有带“;exportAs”;设置为“;matMenu”;

Angular6 角度6错误:模板分析错误:没有带“;exportAs”;设置为“;matMenu”;,angular6,Angular6,我确实有以下代码用于在应用程序中添加mat按钮逻辑,这段代码有什么问题:?我在应用程序模块中添加了应用程序所需的所有相关mat模块 <button mat-icon-button matMenuTriggerFor="menu"> {{selectedValue}} <mat-icon>keyboard_arrow_down</mat-icon> </button> <mat-menu #menu="mat

我确实有以下代码用于在应用程序中添加mat按钮逻辑,这段代码有什么问题:?我在应用程序模块中添加了应用程序所需的所有相关mat模块

 <button mat-icon-button matMenuTriggerFor="menu">
        {{selectedValue}}  <mat-icon>keyboard_arrow_down</mat-icon>
    </button>
    <mat-menu #menu="matMenu">
        <mat-tree [dataSource]="dataSource" [treeControl]="treeControl" class="example-tree">
            <!-- This is the tree node template for leaf nodes -->
            <mat-tree-node *matTreeNodeDef="let node" matTreeNodeToggle>
                <li class="mat-tree-node">
                    <!-- use a disabled button to provide padding for tree leaf -->
                    <button mat-icon-button disabled></button>
                    <button mat-button (click)="myClickFunction(node.name)">
                        {{node.name}}
                    </button>
                </li>
            </mat-tree-node>
            <!-- This is the tree node template for expandable nodes -->
            <mat-nested-tree-node *matTreeNodeDef="let node; when: hasChild">
                <li>
                    <div class="mat-tree-node">
                        <button mat-icon-button matTreeNodeToggle
                                [attr.aria-label]="'toggle ' + node.name">
                            <mat-icon class="mat-icon-rtl-mirror">
                                {{treeControl.isExpanded(node) ? 'expand_more' : 'chevron_right'}}
                            </mat-icon>
                        </button>
                        <button mat-button (click)="myClickFunction(node.name)">
                            {{node.name}}
                        </button>
                    </div>
                    <ul [class.example-tree-invisible]="!treeControl.isExpanded(node)">
                        <ng-container matTreeNodeOutlet></ng-container>
                    </ul>
                </li>
            </mat-nested-tree-node>
        </mat-tree>
    </mat-menu>

{{selectedValue}}键盘箭头向下
  • {{node.name}
  • {{treeControl.isExpanded(节点)?'expand_more':'chevron_right'} {{node.name}
  • 我得到这个错误:

    compiler.js:1021 Uncaught Error: Template parse errors:
    There is no directive with "exportAs" set to "matMenu" ("
            {{selectedValue}}  <mat-icon>keyboard_arrow_down</mat-icon>
        </button>
        <mat-menu [ERROR ->]#menu="matMenu">
            <mat-tree [dataSource]="dataSource" [treeControl]="treeControl" class="exam"): ng:///ComponentsModule/TabularTreeComponent.html@32:14
    
    compiler.js:1021未捕获错误:模板分析错误:
    没有将“exportAs”设置为“matMenu”的指令(“
    {{selectedValue}}键盘箭头向下
    ]#menu=“matMenu”>
    
    请在RootModule中注册MatMenuModule

    import {MatMenuModule} from '@angular/material';
    
    imports: [
     BrowserModule,
     MatMenuModule
    ]
    
    这里有一个