Angular Language Service无法与VS Code一起使用,可能是追踪问题的方法 [英] Angular Language Service not working with VS Code, probable ways to trace the issue

查看:162
本文介绍了Angular Language Service无法与VS Code一起使用,可能是追踪问题的方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是Anuglar v4,并且安装了Angular Language Service扩展及其VS代码包,但没有在HTML中获得任何智能感知,也没有在VS代码开发人员工具中出现任何错误.

解决方案

即使在堆栈溢出后执行了几个线程之后,我也无法解决该问题,并且当我发现该修复想法涵盖了单个帖子中的所有单个步骤时为了节省别人的时间,如果您也遇到类似的问题,请检查以下内容以纠正根本原因.

基于此角度文档

点击它,我们可以看到它的进度

  1. 现在转到帮助->切换开发人员工具(Ctrl + Shift + I),以检查VS Code或Angular Language Service扩展的任何错误[请参阅:https://stackoverflow.com/questions/54393646/angular-language-service-not-working-in-vscode]

  2. 就我而言,到目前为止,根据 https://angular.io/guide/language-service 一些最新的编辑器,我们不需要将Angular Language Service包添加到package.json,但是无法通过上述语句找到任何特定的Angular版本信息.

  3. 当我使用的是更旧的角度版本时,安装了相关软件包 npm i --save-dev @ angular/language-service @ 4.xx ,以确保我是否是否缺少任何必需的包裹

  4. 即使按照上述步骤操作,我也无法获得任何智能感知和VS Code Developer Tool仍然没有任何错误

  • 因此,我已经根据此错误检入了代码在HTML文件中未找到变量"的定义.似乎组件未与HTML文件链接.

  • 能够在我声明组件组件'AppComponent'时看到错误,即使它具有template或templateUrl ng 提供了.

  • 后来能够发现,由于使用了SystemJS/Webpack, template:引起问题的require('./app.html')语法

  • 将其替换为 templateUrl:'./app.html',现在HTML能够检测组件变量,方法等.

参考文献:

让我知道某人是否由于其他原因遇到类似问题,我将更新此线程以节省某人的时间.

I'm on Anuglar v4 and had installed Angular Language Service extension and its package for VS code, neither getting any intellisense in HTML nor any error in VS code developer tools.

解决方案

Even After following couple of thread on stack overflow I was not able to fix the issue, and when I found the fix thought to cover all individual steps in single post to save someone's time, if you are also facing similar issue, please check below things to rectify root cause.

Based on this angular documentation https://angular.io/guide/language-service we can just install Angular Language Extension from VS code and HTML Intellisense should work, in my case I was not getting any Intellisnense in VS code even after this installing this extension: https://marketplace.visualstudio.com/items?itemName=Angular.ng-template

  1. When we load project/solution in vs code, it initialize Angular Language Service extension look at bottom, to check extension's successful initialization.

on click of it we can see it's progress

  1. Now go to Help -> Toggle Developer Tools (Ctrl + Shift + I) to check any error with VS Code or extension for Angular Language Service [Refer: https://stackoverflow.com/questions/54393646/angular-language-service-not-working-in-vscode]

  2. In My case till now everything looks good, as per https://angular.io/guide/language-service some latest editors, we don't need to add Angular Language Service Package to package.json, but was not able to find any specific angular version information with above statement.

  3. As I'm on still older angular version Installed relevant package npm i --save-dev @angular/language-service@4.x.x, to make sure if I'm missing any required package or not

  4. Even after following above steps, I was not able to get any intellisense and still there wasn't any error in VS Code Developer Tool

  • So, I've checked in my code based on this error No definition found for 'variable' from HTML file. Seems like component is not linked with HTML file.

  • Was able to see error on my declaration of component Component 'AppComponent' must have a template or templateUrl ng even though it was provided.

  • Later was able to found that due to SystemJS/Webpack we have used template: require('./app.html') syntax which was causing issue

  • Replacing it to templateUrl: './app.html', Now HTML is able to detect to component variables, methods etc..

References:

Let me know if someone faced similar issue because of any other reason, I'll update this thread to save someone's time.

这篇关于Angular Language Service无法与VS Code一起使用,可能是追踪问题的方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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