cgarvis / angular-toggle-switch

AngularJS Toggle Switch
http://cgarvis.github.io/angular-toggle-switch
MIT License
160 stars 124 forks source link

Unable to switch the toggle #25

Closed EgidioCaprino closed 10 years ago

EgidioCaprino commented 10 years ago

Hi.

I'm unable to use this module. I get this error when I try to change the status of the switcher.

Error: [$compile:nonassign] Expression 'undefined' used with directive 'toggleSwitch' is non-assignable!

I included the angular-toggle-switch.js file and added the module to my app in this way.

var module = angular.module("app", ["ngRoute", "ngResource", "angularFileUpload", "ui.bootstrap", "ui.bootstrap.datetimepicker", "toggle-switch"]);

Where I'm wrong?

cgarvis commented 10 years ago

Did you give the toggle switch a model? There are some examples at http://cgarvis.github.io/angular-toggle-switch/

EgidioCaprino commented 10 years ago

Yes, I do it in this way.

<toggle-switch data-ng-model="currentAlbum.isActive" on-label="Si" off-label="No"><toggle-switch>

But when I try to switch it I get the error above.

cgarvis commented 10 years ago

use just data-model. I haven't made it so that it integrates with ng-model.

EgidioCaprino commented 10 years ago

Thank you :)

What about CSS? Do I have to include the one from the original Bootstrap Switch plugin? I ask because the style of the toggle is this one.

image

cgarvis commented 10 years ago

There is a angular-toggle-switch.css that does basic styling. There is also a angular-toggle-switch-bootstrap.css that will give you bootstrap 2 styling.

EgidioCaprino commented 10 years ago

Thank you :)

FPurchess commented 10 years ago

unfortunately, I hit the same error because the documentation references to an "ng-model" attribute. In fact, it only takes "data-model" into account.

robertguitink commented 10 years ago

Same for me.