简体   繁体   English

Angular 2 组件-“找不到...的定义”

[英]Angular 2 Component - "No definition found for ..."

I'm working with angular 2 in VSCode.我正在 VSCode 中使用 angular 2。 I'm just learning my way around this IDE.我只是在学习这个 IDE。 I'm trying to figure out how to use CTRL+Click to navigate to component properties like templatUrl but it's not working for me (See screenshot).我试图弄清楚如何使用 CTRL+Click 导航到诸如templatUrl之类的组件属性,但它对我不起作用(见截图)。

I would expect that when I CTRL+Click the text it opens the file dashboard.component.html Is there an extension I need to install to get this to work?我希望当我按 CTRL+单击文本时,它会打开文件dashboard.component.html是否需要安装扩展程序才能使其正常工作?

在此处输入图片说明

As far as I am aware, the ctrl + click only works on entities that the language service (Typescript language service) can expose to the IDE.据我所知, ctrl + click 仅适用于语言服务(Typescript 语言服务)可以向 IDE 公开的实体。

For example, you can ctrl + click to navigate to DashboardComponent from app module where you import them.例如,您可以 ctrl + 单击以从导入它们的应用程序模块导航到 DashboardComponent。 The templateUrl property is a string and ctrl + click does not work there. templateUrl 属性是一个字符串,ctrl + click 在那里不起作用。

Alternate option (that I use) is to press ctrl + P that brings up the 'Go To File' popup and you can start typing 'dashboard html' - it actually uses a regex pattern search (dashoboard.component.html, dashboarddetails.component.html etc) to find matches and display them in a dropdown from which you can use the up or down arrow keys and hit enter to navigate to that file.替代选项(我使用的)是按 ctrl + P 以弹出“转到文件”弹出窗口,您可以开始输入“仪表板 html” - 它实际上使用正则表达式模式搜索(dashoboard.component.html、dashboarddetails.component .html 等)以查找匹配项并将它们显示在下拉列表中,您可以从中使用向上或向下箭头键并按 Enter 导航到该文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM