xpepermint / angular-ui-switch

On/off switch button for AngularJS. DEPRECATED!
278 stars 125 forks source link

How do i disable or make this control readonly #22

Closed rakeshch closed 9 years ago

rakeshch commented 9 years ago

Hi,

I like the control. It's simple to use. But only problem is I am not able to set ng-disabled/ readonly property on this control?

Thanks, Rakesh

rakeshch commented 9 years ago

referring to question #9

gajanak commented 9 years ago

I needed to use one-way binding. its a very small change: It's some kind of read-only ;)

replace html += ' ng-class="{ checked:' + attrs.ngModel + ' }"'; by html += ' ng-class="{ checked:' + (attrs.ngModel || attrs.state ) + ' }"';

now you can remove ng-model and set << switch state="ctrl.state" ng-click="ctrl.enable()" >

Perhaps this helps someone else too.

scamjayi commented 9 years ago

I have the same problem. It would be great if you could fix it.

xpepermint commented 9 years ago

https://github.com/xpepermint/angular-ui-switch/pull/23

rakeshch commented 9 years ago

Awesome, thanks so much.