AngularJs ng-disabled is not working in IE 9 any solution?

让人想犯罪 __ 提交于 2020-01-02 04:55:11

问题


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

<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>

回答1:


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>

And in the controller:

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

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>

Controller:

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
   }
}


来源:https://stackoverflow.com/questions/31074683/angularjs-ng-disabled-is-not-working-in-ie-9-any-solution

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!