角度:TypeError:未定义不是对象(正在评估'this.body.toggle')

时间:2018-08-30 14:49:42

标签: angular mdbootstrap

我的角度应用程序有问题。我收到此错误:

[Error] ERROR – TypeError: undefined is not an object (evaluating 'this.body.toggle')

在Chrome控制台中,这是指以下HTML部分:

<mdb-accordion-item *ngFor="let item of menuitems" [ngClass]="{'no-collase': item.submenu.length == 0}">
                    <mdb-accordion-item-head mdbWavesEffect>
                        <fa-icon [icon]="item.icon" class="icon"></fa-icon> {{ 'webapp.menu.' + item.key | translate:lang }}
                    </mdb-accordion-item-head>
                    <mdb-accordion-item-body *ngIf="item.submenu.length != 0">
                            <ul>
                                <li *ngFor="let subitem of item.submenu"> 
                                    <a class="nav-link waves-light" mdbWavesEffect routerLink="{{subitem.routerlink}}">
                                        <fa-icon [icon]="subitem.icon" class="icon"></fa-icon>
                                        <span class="clearfix d-none d-sm-inline-block">{{ 'webapp.menu.' + subitem.key | translate:lang }}</span>
                                    </a>
                                </li>
                            </ul>
                        </mdb-accordion-item-body>
                </mdb-accordion-item>

我的“菜单”数组如下所示:

menuitems:any[] = [
    {key: "dashboard", routerlink: "/settings", icon: this.faDashboard, submenu: []},
    {key: "settings", routerlink: "/settings", icon: this.faCog, submenu: []}
  ];

也许有人对我有帮助。...我在Pro版本中将MDBootstrag用于Angular。

0 个答案:

没有答案