AngularJs ng-disabled无法在IE 9中正常工作吗? [英] AngularJs ng-disabled is not working in IE 9 any solution?

查看:50
本文介绍了AngularJs ng-disabled无法在IE 9中正常工作吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对禁用ng的AngularJs指令有疑问,该指令在chrome中工作正常,但在IE 9中不工作,任何使它工作的解决方案将不胜感激.

I have issue with ng-disabled AngularJs directive its working good in chrome but its not working in IE 9 , Any solution to make it work will be appreciated.

main.html

main.html

<select kendo-drop-down-list k-data-text-field="'text'"
    k-option-label="'Select'" k-data-value-field="'id'"
    k-data-source="assessmentOptions" name="riskAssesLevelLookupCode"
    required id="riskAssesLevelLookupCode"
    maxlength="256"
    ng-attr-disabled="{{disableAssessmentType? 'disabled': ''}}"
    ng-model="riskAssessmentDTO.riskAssesLevelLookupCode"
></select>

推荐答案

我目前在 ng-disabled 上遇到了同样的问题.不幸的是,我唯一想到的解决方法是处理控制器中 ng-disabled 的逻辑.因此,在您的情况下:

I'm currently having the same issue with ng-disabled. Unfortunately, the only workaround that I could think of was to handle the logic of the ng-disabled in the controller. So in your case:

<select kendo-drop-down-list k-data-text-field="'text'"
    k-option-label="'Select'" k-data-value-field="'id'"
    k-data-source="assessmentOptions" name="riskAssesLevelLookupCode"
    Required id="riskAssesLevelLookupCode"
    maxlength="256"
    ng-attr-disabled="checkForDisabled()"
    ng-model="riskAssessmentDTO.riskAssesLevelLookupCode">
</select>

在控制器中:

checkForDisabled() {
    if(disableAssessmentType) {
       return "disabled";
    } else {
       return "";
    }
}

然后再次,这不会保证IE9上的正确行为.就我而言,我试图避免 ng-click 事件的功能.因此,当设置了禁用状态时,我将标志设置为 false ,并根据该标志调用该函数.像这样:

Then again, this won't garanty the right behavior on IE9. In my case I was trying to avoid the functionality of an ng-click event. So I set a flag to false when the disabled was set and according to that flag I called the function. Something like this:

<button ng-click="callMethod()" ng-disabled="checkDisabled()">
  Click me if Im enabled
</button>

控制器:

checkDisabled() {
   // Let's say it's disabled
   $scope.isDisabled = false; // set a global flag
   return false;
}

callMethod() {
   if($scope.isDisabled) {
        //disabled, do nothing maybe handle an error?
   } else {
        //functionality when it's enabled
   }
}

这篇关于AngularJs ng-disabled无法在IE 9中正常工作吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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