Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
110 views
in Technique[技术] by (71.8m points)

AngularJS intellisense not working on Visual Studio 2015

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.

image

Here's what I did:

  1. Added the angular.intellisense.js to the global javascript references at C:Program Files (x86)Microsoft Visual Studio 14.0JavaScriptReferences
  2. 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)
  • 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

.

question from:https://stackoverflow.com/questions/29830266/angularjs-intellisense-not-working-on-visual-studio-2015

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.

  1. Go to https://www.angularjs.org and pull up the download dialog box.

Download AngularJS Dialog Box

  1. Copy the Uncompressed CDN url. Today that happens to be https://ajax.googleapis.com/ajax/libs/angularjs/1.4.4/angular.js
  2. In Visual Studio 2015 RTM, go to Tools, Options, Text Editor, Javascript, Intellisense, References. Choose the appropriate Reference Group; for most web project this is Implicit (Web). Paste the url at the bottom text box and click the Add button. Don't dismiss the dialog box yet. enter image description here
  3. Under Text Editor, Javascript, Intellisense, General, make sure the check box is checked for Download remote references.
  4. Click the OK button.
  5. (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 a Scripts 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.
  6. You may need to disable intellisense in Resharper for javascript if it interferes with the native intellisense.
  7. 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.

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...