我正在使用安古拉2-mdl构建一个应用程序。一切都很好,除了所有的动画都不能工作。
在查看了以下链接中可用的文档之后,我注意到,例如,如果我想在单击按钮后切换特定菜单,则必须使用如下语法:
<button mdl-button #btn1="mdlButton" (click)="m1.toggle($event, btn1)" mdl-button-type="icon" mdl-ripple><mdl-icon>more_vert</mdl-icon></button>
<mdl-menu #m1="mdlMenu" mdl-menu-position="bottom-left">
<mdl-menu-item mdl-ripple (click)="action()">Some Action</mdl-menu-item>
<mdl-menu-item mdl-ripple mdl-menu-item-full-bleed-divider>Another Action</mdl-menu-item>
<mdl-menu-item mdl-ripple disabled>Disabled Action</mdl-menu-item>
<mdl-menu-item>Yet Another Action</mdl-menu-item>
</mdl-menu>菜单的文档可用这里。
不幸的是,当我试图用以下代码复制相同的行为时:
button(mdl-button, mdl-button-type='icon', '#morebtn'="mdlButton" '(click)'="moremenu.toggle($event, morebtn)")
mdl-icon more_vert
mdl-menu(mdl-menu-position='bottom-right', '#moremenu'="mdlMenu")
mdl-menu-item About
mdl-menu-item Contact
mdl-menu-item Legal Information被编译为:
<button mdl-button="mdl-button" mdl-button-type="icon" #morebtn="mdlButton" (click)="moremenu.toggle($event, morebtn)">
<mdl-icon>more_vert</mdl-icon>
</button>
<mdl-menu mdl-menu-position="bottom-right" #moremenu="mdlMenu">
<mdl-menu-item>About</mdl-menu-item>
<mdl-menu-item>Contact</mdl-menu-item>
<mdl-menu-item>Legal Information</mdl-menu-item>
</mdl-menu>我知道我在标题中提到的错误。下面的pasted.co日志提供了一个完整的错误跟踪。
过去,我在使用ngForm时遇到了类似的问题,我通过在抛出错误的组件上导入import { NgForm } from '@angular/forms';来解决这个问题。
所以我想要导入mdlButton和mdlMenu已经有一段时间了
import { MdlButtonComponent } from '@angular-mdl/core/components/button/mdl-button.component';
import { MdlMenuComponent } from '@angular-mdl/core/components/menu/mdl-menu.component';但错误依然存在。
我有两个模块:
app.module.ts:导入MdlModule以使其对整个应用程序可用pages.module.ts:在这里我导入页面中所需的所有组件,尽管我正在跟踪文档,但我为什么要得到这个呢?我怎样才能解决这个问题?
https://stackoverflow.com/questions/46073543
复制相似问题