ng-template 错误:模板上下文未定义名为...的成员(Kendo Grid) [英] ng-template Error: The template context does not define a member called ... (Kendo Grid)

查看:25
本文介绍了ng-template 错误:模板上下文未定义名为...的成员(Kendo Grid)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 Angular 中尝试将 ng-template 与 Kendo Grid 一起使用时遇到问题.我拥有的 html 是有效的,并且在启动时可以正常编译和运行,但是 Visual Studio Code 显示此错误:

I have an issue when trying to use ng-template with Kendo Grid in Angular. The html I have is valid and compiles and functions properly when launched, but then Visual Studio Code shows this error:

模板上下文没有定义名为 column 的成员

The template context does not define a member called column

这是我的代码:

<kendo-grid-column field="countryID"
  title="{{ 'location.country' | translate }}"
  width="10">
  <ng-template kendoGridEditTemplate
    let-dataItem="dataItem"
    let-column="column"
    let-formGroup="formGroup">
    <app-dropdown-single
      [placeholder]="column.title"
      [formControl]="formGroup?.controls['countryID']"
      [data]="dataDdwCountry"
      valueField="id">
    </app-dropdown-single>
  </ng-template>
</kendo-grid-column>

所以 Visual Studio Code 给了我 ng-template 的 3 个参数的错误.但是,编译时占位符确实显示了列"的正确值.如果我只留下它 **let-column** 而不是 **let-column="column"** 错误消失,但我需要的值也是如此(列现在未定义,我需要该值).

So Visual Studio Code gives me the error for the 3 parameters of the ng-template. However, when compiled the placeholder does show the correct value of "column". If I leave it just **let-column** instead of **let-column="column"** the error disappears, but so does the value I need (column is now left undefined and I need the value).

有人可以帮忙吗?

推荐答案

更新:Angular 语言服务版本 v0.900.11+ 似乎已经解决了这个 ng-template 错误,请在回滚到任何以前的版本之前尝试该版本或更高版本,如下所示.

Update: This ng-template error appears to have been resolved by Angular Language Service version v0.900.11+ Please try that version or greater before rolling back to any previous version as indicated below.

原文:这与在 VS Code 中运行的 Angular Language Service 扩展有关.具体而言,当前高于 v0.900.4 的任何服务版本.通过查看 VS Code 中已安装的扩展选项卡,检查您当前安装的 Angular 语言服务版本.

Original: This is related to the Angular Language Service extension running in VS Code. Specifically, any version of the service that is currently greater than v0.900.4. Check which version of the Angular Language Service you currently have installed by looking at the installed extensions tab in VS Code.

在 Angular 语言服务团队或 Kendo UI 团队修复此问题之前(不确定谁有错),您可以暂时禁用 VS Code 中扩展的自动更新并安装 Angular 语言的 v0.900.4 版本通过从此处的 GitHub 发布页面安装 .vsix 文件来提供服务:https://github.com/angular/vscode-ng-language-service/releases/tag/v0.900.4

Until either this is fixed by the Angular Language Service team or the Kendo UI team (not sure who is at fault), you can temporarily disable auto updating of extensions in VS Code and install version v0.900.4 of the the Angular Language Service by installing the .vsix file from the GitHub Releases page here: https://github.com/angular/vscode-ng-language-service/releases/tag/v0.900.4

安装 .vsix 文件的说明位于 VS Code 中出现的 Angular 语言服务的扩展信息页面上,当您单击扩展选项卡中的扩展时.我把它们包括在这里:

The instructions for installing the .vsix file are on the extension info page for the Angular Language Service that comes up in VS Code when you click on the extension in the extensions tab. I included them here:

安装特定的发布版本

下载要安装的版本的 .vsix 文件发布标签.

Download the .vsix file for the release that you want to install from the releases tab.

不要直接打开 .vsix 文件.相反,在 Visual Studio 代码中,转到扩展选项卡.点击右上角的..."菜单在扩展选项卡的一角,选择从 vsix 安装...",然后为您刚刚下载的版本选择 .vsix 文件.

Do not open the .vsix file directly. Instead, in Visual Studio code, go to the extensions tab. Click on the "..." menu in the upper right corner of the extensions tab, select "Install from vsix..." and then select the .vsix file for the release you just downloaded.

也可以使用以下命令安装扩展:

The extension can also be installed with the following command:

code --install-extension/path/to/ngls.vsix

code --install-extension /path/to/ngls.vsix

这篇关于ng-template 错误:模板上下文未定义名为...的成员(Kendo Grid)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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