AngularJS 智能感知不适用于 Visual Studio 2015 [英] AngularJS intellisense not working on Visual Studio 2015
问题描述
根据这个 并打开下载对话框.
- 复制未压缩的 CDN 网址.今天恰好是
- 在
Text Editor, Javascript, Intellisense, General
下,确保选中Download remote references
复选框. - 点击确定按钮.
- (可选)如果您想要为您创建的 angular 提供程序(不是 angular 框架的一部分)提供智能感知,请将
_references.js
添加到您的项目的根目录.不要费心制作Scripts
文件夹.右键单击它并选择自动同步,然后选择更新.进入它并删除由构建过程创建的任何 js 文件.如果你不这样做,它们可能会很大,以至于会破坏智能感知.第一次使用智能感知时,请准备好大约 5-10 秒的延迟,因为它必须从您的项目中加载所有这些引用. - 您可能需要在 Resharper 中为 javascript 禁用智能感知,如果它干扰了原生智能感知.
- 重新启动 Visual Studio.除非你这样做,否则它不会工作.此外,我对首先关闭除此实例以外的所有其他实例感到偏执,因此这些设置坚持".因此,我建议您在重新启动此实例之前执行此操作.
According to this post intellisense should also be working on the new VS 2015, but so far I only get intellisense for the angular object and not for the dependencies or my custom modules.
Here's what I did:
- Added the angular.intellisense.js to the global javascript references at
C:\Program Files (x86)\Microsoft Visual Studio 14.0\JavaScript\References
- Restarted VS2015 And then nothing, it just showed exclamation marks whenever I tried to use intellisense on a $http object.
I also added the file to the same place as my angular.js but it still didn't work. The question that I have in this case is, where should I place the file? on the angular public folder with only my angular.js, or on my dev angular folder where all the files downloaded from bower are.
I also tried addind it directly into the tools/options/text editor/javascriptr/intellisense/reference menu, on the Implicit(Web) reference group, but it still didn't work.
On my project I have the following folder structure inside the src folder:
- wwwroot
- app (my angular site stuff)
- controllers
- services
- views
- lib (js dependencies, only the .min.js file of each library)
- angular
- angular-route
- ....
- _references.js (the visual studio js references file, contains reference to the files inside the app and lib folders)
- app (my angular site stuff)
- Libraries (contains the full libraries as downloaded by bower)
- angular
- angular-route
- ...
As a side note, I don't have a /scripts folder and therefore no /scripts/_references.js
file
.
This was not working for me in Visual Studio 2015 RTM in a web project, but I solved the problem.
This project was not created with Visual Studio and does not have a _references.js
file anywhere. So I think this will work in any situation.
I removed all other intellisense resources from within the VS UI to make sure what I did was what fixed it.
- Go to https://www.angularjs.org and pull up the download dialog box.
- Copy the Uncompressed CDN url. Today that happens to be https://ajax.googleapis.com/ajax/libs/angularjs/1.4.4/angular.js
- In Visual Studio 2015 RTM, go to
Tools, Options, Text Editor, Javascript, Intellisense, References
. Choose the appropriate Reference Group; for most web project this isImplicit (Web)
. Paste the url at the bottom text box and click the Add button. Don't dismiss the dialog box yet. - Under
Text Editor, Javascript, Intellisense, General
, make sure the check box is checked forDownload remote references
. - Click the OK button.
- (optional) If you want intellisense for the angular providers that you create (not part of the angular framework), add
_references.js
to the root of your project. Don't bother making aScripts
folder. Right click on it and choose auto-sync, then choose update. Go into it and remove any js files created by a build process. If you don't, they can be so large they will break intellisense. Be prepared for a ~5-10 second delay the first time you use intellisense, as it has to load all these references from your project. - You may need to disable intellisense in Resharper for javascript if it interferes with the native intellisense.
- Restart Visual Studio. It will not work until you do this. Also, I'm paranoid about closing all other instances other than this instance first, so these settings "stick". So I suggest you do that before restarting this instance.
这篇关于AngularJS 智能感知不适用于 Visual Studio 2015的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!