Angular2与材料设计精简版 [英] Angular2 with Material Design Lite

查看:185
本文介绍了Angular2与材料设计精简版的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我添加code以下位在我angular2应用程序来帮助周围的移动应用程序时MDL重新注册组件...

I have added the following bit of code in my angular2 app to help MDL re-register the components when moving around the app...

ngAfterViewInit() {
    componentHandler.upgradeDom();
}

虽然它似乎是工作正常(如预期),我收到以下错误...

And although it seems to be working ok (as expected) I am getting the following error...

(16,5): error TS2304: Cannot find name 'componentHandler'.

我还是很新的angular2和打字稿,但我想我需要让我的code知道的ComponentHandler是(即使它必须知道它是什么,因为它的工作原理,并没有这个不起作用进口的东西code 1-3混淆)

I'm still quite new to angular2 and typescript but I guess I need to import something so my code knows what componentHandler is(even though it must know what it is because it works and doesn't work without this code??? confused)

推荐答案

它应该帮助你添加

declare var componentHandler: any;

在你code的顶部。请参考相应的手册部分上的与其他JavaScript库的打字稿中工作。

这篇关于Angular2与材料设计精简版的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆