最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

angularjs - Enabling javascript intellisense for external libraries in Visual Studio - Stack Overflow

programmeradmin1浏览0评论

I updated ~/Scripts/_references.js with

/// <autosync enabled="true" />
/// <reference path="angular.js" />
/// <reference path="angular-route.js" />

and in my app.js I can see some intellisense working, which is great

but go a little further and it doesn't work anymore.

Any ideas on why this happens or ways to make it work?

I updated ~/Scripts/_references.js with

/// <autosync enabled="true" />
/// <reference path="angular.js" />
/// <reference path="angular-route.js" />

and in my app.js I can see some intellisense working, which is great

but go a little further and it doesn't work anymore.

Any ideas on why this happens or ways to make it work?

Share Improve this question asked Dec 13, 2013 at 14:43 kenwarnerkenwarner 29.1k31 gold badges133 silver badges174 bronze badges
Add a comment  | 

2 Answers 2

Reset to default 8

Because you are using dependency injection, Visual Studio has no way to figure out what are the types of the arguments.

This is a common problem with Javascript intellisense and, since Javascript does not allow for explicit type annotations, it seems that there is no clear way to work around it.

However, this can be achieved easily using Typescript (which has a VS2013 extension) and angular types where your code would look like:

angular.module('example', ['ngRoute'])
  .config([ '$locationProvider',
    function ($locationProvider : ng.ILocationProvider) {

           $locationProvider. // Intellisense would work here.
    }
   ]);

I built a library to do just this:

https://github.com/jmbledsoe/angularjs-visualstudio-intellisense

发布评论

评论列表(0)

  1. 暂无评论