Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
673 views
in Technique[技术] by (71.8m points)

Build Nested Angular Material MatMenu with *ngFor got errors

I try to build nested(two levels) MatMenu in angular material components, but when I run it in browser, errors occurred.

component.html:

<!-- header -->
<div class="header">
    <!-- nav -->
    <div class="nav">
        <ng-container *ngFor="let navMenu of navMenus">
            <button mat-button [matMenuTriggerFor]="btnMenu">{{ navMenu.name }}</button>
            <mat-menu #btnMenu="matMenu">
                <ng-container *ngFor="let menu of navMenu.menus">
                    <ng-container *ngIf="!menu.children">
                        <a mat-button mat-menu-item href="{{ menu.url }}" target="_blank">{{ menu.name }}</a>
                    </ng-container>
                    <ng-container *ngIf="menu.children">
                        <button mat-button *ngIf="menu.children" [matMenuTriggerFor]="parentMenu"
                            mat-menu-item>{{ menu.name }}</button>
                        <mat-menu #parentMenu="matMenu">
                            <ng-container *ngFor="let child of menu.children">
                                <a mat-button mat-menu-item href="{{ child.url }}" target="_blank">{{ child.name }}</a>
                            </ng-container>
                        </mat-menu>
                    </ng-container>
                </ng-container>
            </mat-menu>
        </ng-container>
    </div>
</div>
question from:https://stackoverflow.com/questions/65626209/build-nested-angular-material-matmenu-with-ngfor-got-errors

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...