javascript 此处不允许使用属性 ng-model
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/31774815/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Attribute ng-model not allowed here
提问by Nick Thoma
I am trying to use the ng-model attribute on a dropdown, however WebStorm keeps telling that it is not allowed. When I run the app, it is not bound so I thinking it has do with my Angular version. I am running the latest version, and ng-model seems to work on all other elements besides select. Has something changed within the last update?
我试图在下拉列表中使用 ng-model 属性,但是 WebStorm 一直告诉它是不允许的。当我运行该应用程序时,它不受约束,所以我认为它与我的 Angular 版本有关。我正在运行最新版本,并且 ng-model 似乎适用于除 select 之外的所有其他元素。上次更新有什么变化吗?
<div class="form-group">
<label for="selectPost" class="control-label">Posts</label>
<select ng-model="post" class="form-control" id="selectPost" >
<option ng-repeat="post in currentUser.posts" value="{{post._id}}">
{{post.name}}
</option>
</select>
</div>
回答by A-S
change ng-model
into data-ng-model
,
it is a known WebStorm bug
更改ng-model
为data-ng-model
,这是一个已知的 WebStorm 错误
回答by Keith McNamee
This may not be the solution to your problem, but I was getting "not allowed here" for a lot Angular attributes inexplicably.
这可能不是您问题的解决方案,但我莫名其妙地得到了很多 Angular 属性的“此处不允许”。
It turned out that I had excluded the folder that included the angular.js from my project so that it didn't bother me with my normal day to day. It meant that the page worked fine when created but Webstorm wasn't able to read it as I was writing the code
结果是我从我的项目中排除了包含 angular.js 的文件夹,这样我的日常工作就不会打扰我。这意味着该页面在创建时运行良好,但在我编写代码时 Webstorm 无法读取它