为什么AngularJS指令(属性等)显示为“无效"?在WebStorm 8中? [英] Why do AngularJS directives (attributes, etc.) show up as "invalid" in WebStorm 8?

查看:117
本文介绍了为什么AngularJS指令(属性等)显示为“无效"?在WebStorm 8中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

几个小时前我刚刚安装了WebStorm 8.我一直在写一些AngularJS的东西,但是我有一个很烦人的小问题.每当我键入ng-时,AngularJS插件似乎都可以部分工作,我会得到一个显示所有ng- *属性的智能提示弹出窗口.但是,那是事情停止工作的地方.我似乎没有在.js文件或.html文件中获得更高级的智能感知功能.如果我在app.js中创建一个名为"app"的角度模块,那么当我在HTML文件中键入ng-app=时,"app"不会显示.此外,在编辑html文件时,WebStorm会将所有ng- *属性突出显示为无效的html.其他的angularjs功能似乎都不起作用.例如,我在绑定中没有任何智能感知.

I just installed WebStorm 8 a couple of hours ago. I've been writing some AngularJS stuff, and I have a rather annoying little problem. The AngularJS plugin seems to work partially, whenever I type ng- I get an intellisense popup that shows all the various ng-* attributes. However, that's where things stop working. I do not seem to be getting the more advanced intellisense capabilities in either .js files or .html files. If I create an angular module called "app" inside app.js, then "app" does NOT show up when I type ng-app= in the HTML file. Additionally, WebStorm highlights all ng-* attributes as invalid html when editing the html file. None of the other angularjs features seem to work, either. I don't get any intellisense in bindings, for example.

我在SO上找到了一些主题,这些主题指示我可能需要在项目设置中将AngularJS添加为JavaScript库...但是有关于正确执行此操作的零指示. SO的主题非常简短,可以链接到非常通用的WebStorm文档,没有任何细节.如何在WebStorm中将AngularJS设置为JS库?真的有必要吗?

I've found some topics here on SO that indicate I may need to add AngularJS as a JavaScript Library in the project settings...however there are ZERO instructions on how to do that properly. The topics on SO are very short and link to WebStorm documentation which is very general, without any specifics. How exactly does one set up AngularJS as a JS library within WebStorm? Is that even really necessary?

我应该注意,AngularJS确实确实在WebStorm的设置中显示为插件,并且已对其进行了检查.我基本上只有ng- *属性intellisense,但是我没有获得WebStorm 8附带的其他AngularJS增强支持.我已经安装和卸载了Webstorm两次.不太确定该从哪里去...

I should note that AngularJS does indeed show up in WebStorm's settings as a plugin, and it is checked. I basically only have ng-* attribute intellisense, but I get none of the other AngularJS enhanced support that was supposed to come with WebStorm 8. I've installed and uninstalled webstorm completely a couple of times. Not really sure where to go from here...

推荐答案

要将Angular JS添加为项目库,请访问

To add Angular JS as a Project library go to

Preferences > Project Settings > JavaScript > Libraries > Add

,然后选择Angular目录将其添加.

and then select the Angular directory to add it.

我在Mac上,但Windows应该大致相似.

I'm on a Mac but windows should be roughly similar.

您也可以

ctrl/cmd + shift + a

(转到任何地方)并输入库以到达同一位置.

(go to anywhere) and type libraries to get to the same place.

注意:我的主要html文件中已通过 https:/引用了Angular/ajax.googleapis.com/ajax/libs/angularjs/1.0.8/angular.min.js ,它可以在不将其添加为库的情况下正常工作.

Note: I have Angular referenced in my main html file via https://ajax.googleapis.com/ajax/libs/angularjs/1.0.8/angular.min.js and the it works without adding it as a library.

来自Webstorm博客:如果您更喜欢使用CDN,请将光标放在突出显示的库名称上,按Alt + Enter,然后下载库.这将在WebStorm的缓存中(而不是在您的项目中)建立一个本地库,以便WebStorm可以访问AngularJS方法,指令等以进行自动完成和文档查找.

From the Webstorm blog: If you prefer to use a CDN, place the cursor over the highlight library name, hit Alt+Enter, and Download Library. This will set up a local library in WebStorm’s cache (not in your project) so WebStorm can access AngularJS methods, directives, etc for autocompletion and documentation lookup.

这篇关于为什么AngularJS指令(属性等)显示为“无效"?在WebStorm 8中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆