Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/410.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript ng:disabled不适用于select html元素_Javascript_Angularjs - Fatal编程技术网

Javascript ng:disabled不适用于select html元素

Javascript ng:disabled不适用于select html元素,javascript,angularjs,Javascript,Angularjs,我正在写一个基于web的项目,我正在使用angularjs。我在selecthtml元素上发现了ng:disabled指令的小错误。如果元素被禁用,我仍然可以使用键盘上下箭头更改其值。 所以我想实现的是禁用select元素并消除这个小东西 有人能解释一下这个指令是如何工作的吗??我看过angularjs,但无法理解 这是一个错误还是正常的行为,我不能理解的东西 谢谢你提前回复 例如: -选择- 曲目列表 藏品清单 问题似乎是选择框没有失去焦点。指令可以解决这个问题: myApp.direct

我正在写一个基于web的项目,我正在使用angularjs。我在selecthtml元素上发现了ng:disabled指令的小错误。如果元素被禁用,我仍然可以使用键盘上下箭头更改其值。 所以我想实现的是禁用select元素并消除这个小东西

有人能解释一下这个指令是如何工作的吗??我看过angularjs,但无法理解

这是一个错误还是正常的行为,我不能理解的东西

谢谢你提前回复

例如:


-选择-
曲目列表
藏品清单

问题似乎是选择框没有失去焦点。指令可以解决这个问题:

myApp.directive('blur', function () {
  return function (scope, element, attrs) {
    attrs.$observe('blur', function (newValue) {
      newValue != "" && element[0].blur();
    });
  }
});
HTML:


您可能应该与您的选择列表一起使用

myApp.directive('blur', function () {
  return function (scope, element, attrs) {
    attrs.$observe('blur', function (newValue) {
      newValue != "" && element[0].blur();
    });
  }
});
<select ... ng-model="listType" ng-disabled="listType" blur="{{listType}}">