Javascript Angular js ng-disabled 不起作用

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/14704650/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-24 17:40:51  来源:igfitidea点击:

Angular js ng-disabled doesnt work

javascriptangularjs

提问by user2038879

This is my form

这是我的表格

<form name="myForm">
<input ng-disabled="true" type="text" >*
</form>

However I am trying to understand why this input field is not disabled?

但是我想了解为什么这个输入字段没有被禁用?

I also tried with a $scope, so in the CTRL:

我也尝试使用 $scope,所以在 CTRL 中:

$scope.diss=true;

and in html :

并在 html 中:

<form name="myForm">
<input ng-disabled="diss" type="text" >*
</form>

It still doesnt work, any hint?

它仍然不起作用,有什么提示吗?

回答by Ajay Beniwal

Here's a simple working example of the ng-disableddirective:

这是该ng-disabled指令的一个简单工作示例:

<form ng-app> 
   <input ng-disabled="checked" type="text" />
    Click me to disable: <input type="checkbox" ng-model="checked"><br/>
</form> 

回答by Matt DeKrey

I could not use ng-disabled with angular prior to version 1.2.x (I am on 1.0.8) because my jQuery version was 1.4.2.

在 1.2.x 版之前,我无法将 ng-disabled 与 angular 一起使用(我使用的是 1.0.8),因为我的 jQuery 版本是 1.4.2。

angularJS 1.0.x requires jQuery 1.6 or newer.

angularJS 1.0.x 需要 jQuery 1.6 或更新版本。

Upgrading either your jQuery or angularJS will fix the issue - angularJS 1.2.x detects your jQuery version and will fallback to its internal jQLite.

升级您的 jQuery 或 angularJS 将解决该问题 - angularJS 1.2.x 检测您的 jQuery 版本并将回退到其内部 jQLite。