angular-ui-switch icon indicating copy to clipboard operation
angular-ui-switch copied to clipboard

Disabled not working

Open celsomtrindade opened this issue 10 years ago • 6 comments

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.

celsomtrindade avatar Nov 30 '15 12:11 celsomtrindade

There is a way to make it work with ng-disabled?

ido567 avatar Dec 15 '15 08:12 ido567

@ido567 if you change the original file like I did, you can use it normally.

celsomtrindade avatar Dec 20 '15 23:12 celsomtrindade

That's the only way, I really try to avoid that

ido567 avatar Dec 21 '15 06:12 ido567

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

celsomtrindade avatar Dec 21 '15 10:12 celsomtrindade

I found a workaround, using data-disabled:

<switch name="testing" ng-model="testing" data-disabled="isDisabled"></switch>

nicokaen avatar Feb 03 '16 22:02 nicokaen

How can we set it to true or false dynamically on some conditions?

vpgayakwad avatar Feb 16 '17 06:02 vpgayakwad