Angular2 with Material Design Lite
Angular2 with Material Design Lite
我在我的 angular2 应用程序中添加了以下代码,以帮助 MDL 在应用程序中移动时重新注册组件......
ngAfterViewInit() {
componentHandler.upgradeDom();
}
虽然它似乎工作正常(如预期的那样(,但我收到以下错误......
(16,5): error TS2304: Cannot find name 'componentHandler'.
我对 angular2 和打字稿仍然很陌生,但我想我需要导入一些东西,以便我的代码知道 componentHandler 是什么(即使它必须知道它是什么,因为它可以工作并且没有这段代码就不起作用???困惑(
它
应该可以帮助您添加
declare var componentHandler: any;
在代码的顶部。请参考相应的手册部分,在 TypeScript 中使用其他 JavaScript 库。
如果您正在使用 cli.angular 工具来生成应用程序这样做,这样就不需要到处复制代码。
-
将以下行添加到 typings.d.ts 文件中
declare var componentHandler: any;
reference the file into your component file as below
/// <reference path="../typings.d.ts" />
I guess you need to add
declare componentHandler;
componentHandler.upgradeDom();
另请参阅直接从 TypeScript 调用 JavaScript
相关文章:
- 使用电话间隙在Android应用程序中显示SQL Lite的数据
- Backbone.js restful json API design
- 在IE中加载Firebug Lite时出现问题
- 有没有一种方法可以获得three.js的最小/lite版本
- 如何使用angular _ design保持全局当前用户直到注销
- Material Design Lite所有元素加载JS回调
- JavaScript 切换 Material Design Lite 开关
- Material Design Lite菜单动态重复
- Material Design Lite 不能完全与 Angular2 配合使用
- Angular2 with Material Design Lite
- 使用 React 递增 Material Design Lite 进度条
- Material Design Lite JS未应用于动态加载的html文件
- Material Design Lite固定导航行
- 如何在Google Material Design Lite中添加2个滑动菜单
- 使用Material Design Lite复选框高亮显示整个表格行
- Material Design Lite表格-添加行动态打断格式
- Material Design Lite和jQuery,平滑滚动有些问题
- 在AngularJS中使用Material Design Lite
- 如何在Material Design Lite中使用class而不是ID
- 如何在webpack中使用Material Design Lite ?