键入生成在内联模板变量

时间:2016-11-09 09:48:24

标签: angular typescript typescript-typings

在Angular2应用程序(TS)中使用CodeMirror。

我有这段代码<codemirror #editor />,它让我可以轻松访问ElementRef:

@ViewChild('editor') editor: any;

但是,CodeMirror实例本身在this.editor.instance处更深,所以我使用:

this.cmirror = this.editor.instance;

使用CodeMirror API(this.cmirror.setOption('...'));

从UI配置编辑器选项

只要我在ViewChild参考上使用类型any,一切正常。我已经下载了typings file了:

/// <reference path="../../typings/codemirror.d.ts" />

现在任何使用显式类型的尝试都失败了。

我试过了:@ViewChild('editor') editor: ElementRef - 但.instance不存在,所以我在IDE中遇到错误。

对于这样的内联模板引用模式,强烈键入ViewChild引用的正确方法是什么?

0 个答案:

没有答案