简体   繁体   English

Visual Studio代码:找不到名字角?

[英]Visual Studio Code: Cannot find name angular?

I have an Angular App and it works fine, but my debugger is showing me 'Cannot find name angular'. 我有一个Angular应用程序,它工作正常,但我的调试器显示'找不到名字角'。

 var table = angular.module('myTable', ['angularUtils.directives.dirPagination']); 

I included the link for angular in my html file: 我在我的html文件中包含了angular的链接:

<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>

I tried also including a link for bower_components also: 我还尝试了包括bower_components的链接:

<script src="bower_components/angular/angular.min.js"></script>

There is a answer about this problem at Getting Error - Cannot find name 'angular' but I am not able to use it. 获取错误时有一个关于此问题的答案- 找不到名称'angular'但我无法使用它。

单击“angular”旁边的灯泡,然后选择“download typings”。

I was having the same issue until I ran across this article: 在遇到这篇文章之前,我遇到了同样的问题:

http://blogs.msdn.com/b/vscode/archive/2015/05/22/getting-started-with-angular-and-visual-studio-code.aspx http://blogs.msdn.com/b/vscode/archive/2015/05/22/getting-started-with-angular-and-visual-studio-code.aspx

Basically, here's what you have to do with npm: 基本上,这就是你要用npm做的事情:

cd (app path)
npm install -g tsd
tsd init
tsd query angular --action install --save

That's it. 而已。 When you restart VS Code your problem should be gone. 当您重新启动VS Code时,您的问题应该消失。

Note that I didn't use any of the ///reference links as the author suggested in the article, but after the above steps I stopped getting that message about angular not being found and I have already noticed more ng-* options coming through in Intellisense. 请注意,我没有使用文章中作者所建议的任何///引用链接,但在上述步骤之后,我停止获取有关角度未找到的消息,我已经注意到更多ng- *选项通过在Intellisense。

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

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