angular-ui-switch
angular-ui-switch copied to clipboard
Disabled not working
The switch with property 'disabled=true' is not working.
I checked my console and the input didn't had the disabled=true set, so i was able to interact with it anyway.
I added this line and it worked:
html += attrs.disabled ? ' disabled="' + attrs.disabled +'"' : '';
This is the overall input code:
html += '<input type="checkbox"';
html += attrs.id ? ' id="' + attrs.id + '"' : '';
html += attrs.name ? ' name="' + attrs.name + '"' : '';
html += attrs.ngModel ? ' ng-model="' + attrs.ngModel + '"' : '';
html += attrs.disabled ? ' disabled="' + attrs.disabled +'"' : '';
html += ' style="display:none" />';
The code i was using was based on the example provided, like this:
<switch name="testing" ng-model="testing" disabled="true"></switch>
After doing this, everything works fine, even with disabled true/false.
There is a way to make it work with ng-disabled?
@ido567 if you change the original file like I did, you can use it normally.
That's the only way, I really try to avoid that
@ido567 We'll have to wait to see if they have other solution, or other method. I didn't found any other way to solve this. Or maybe I'm missing something.
I found a workaround, using data-disabled:
<switch name="testing" ng-model="testing" data-disabled="isDisabled"></switch>
How can we set it to true or false dynamically on some conditions?