AngularJS 智能感知不适用于 Visual Studio 2015

2024-01-05

根据这个post http://blogs.msdn.com/b/visualstudio/archive/2015/02/05/using-angularjs-in-visual-studio-2013.aspxintellisense 也应该在新的 VS 2015 上工作,但到目前为止,我只获得角度对象的智能感知,而不是依赖项或我的自定义模块的智能感知。

这是我所做的:

  1. 将 angular.intellisense.js 添加到全局 javascript 引用中:C:\Program Files (x86)\Microsoft Visual Studio 14.0\JavaScript\References
  2. 重新启动VS2015 然后什么也没有,每当我尝试在 $http 对象上使用智能感知时,它只是显示感叹号。

我还将该文件添加到与我的 angular.js 相同的位置,但它仍然不起作用。在这种情况下我的问题是,我应该将文件放在哪里?在只有我的 angular.js 的 Angular 公共文件夹中,或者在我的 dev Angular 文件夹中,其中包含从 Bower 下载的所有文件。

我还尝试将其直接添加到隐式(Web)参考组的工具/选项/文本编辑器/javascript/intellisense/参考菜单中,但它仍然不起作用。

在我的项目中,src 文件夹内有以下文件夹结构:

  • wwwroot
    • app (my angular site stuff)
      • 控制器
      • services
      • views
    • lib (js dependencies, only the .min.js file of each library)
      • angular
      • 角度路线
      • ....
    • _references.js(Visual Studio JS 引用文件,包含对 app 和 lib 文件夹内的文件的引用)
  • Libraries (contains the full libraries as downloaded by bower)
    • angular
    • 角度路线
    • ...

顺便说一句,我没有 /scripts 文件夹,因此没有/scripts/_references.js file

.


这在 Web 项目的 Visual Studio 2015 RTM 中对我不起作用,但我解决了问题。

该项目不是使用 Visual Studio 创建的,并且没有_references.js随处归档。所以我认为这在任何情况下都有效。

我从 VS UI 中删除了所有其他智能感知资源,以确保我所做的就是修复它。

  1. Go to https://www.angularjs.org https://www.angularjs.org并弹出下载对话框。
  1. 复制未压缩的 CDN url。今天恰好是https://ajax.googleapis.com/ajax/libs/angularjs/1.4.4/angular.js 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,确保选中该复选框Download remote references.
  4. Click the OK button.
  5. (可选)如果您希望为您创建的角度提供程序(不是角度框架的一部分)提供智能感知,请添加_references.js到你的项目的根目录。不用费心做一个Scripts文件夹。右键单击它并选择自动同步,然后选择更新。进入其中并删除构建过程创建的所有 js 文件。如果不这样做,它们可能太大,会破坏智能感知。第一次使用智能感知时,请做好大约 5-10 秒延迟的准备,因为它必须从项目中加载所有这些引用。
  6. 如果 JavaScript 的 Resharper 中的智能感知干扰了本机智能感知,您可能需要禁用它。
  7. 重新启动 Visual Studio。除非你这样做,否则它不会起作用。另外,我偏执于首先关闭除此实例之外的所有其他实例,因此这些设置“粘住”。因此,我建议您在重新启动此实例之前执行此操作。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

AngularJS 智能感知不适用于 Visual Studio 2015 的相关文章

随机推荐