cgarvis / angular-toggle-switch

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

Possible to change switch values? #76

Open rbarman opened 9 years ago

rbarman commented 9 years ago

Currently it seems that the possible switch values are true and false. Is it possible to add our own values that are more appropriate to our application?

Below is an example of what would be useful. Note the on-value and off-value fields.

        <toggle-switch
            ng-model="ctrl.model.side"
            on-label="For"
            on-value = "For"
            off-label="Against"
            of-value = "Against">
        <toggle-switch>

So in this case, the value for the 'On' case is "For" rather than true. Ideally it would be nice to modify the default values for our own applications. Is there a way to do this?

cgarvis commented 9 years ago

If it's something you would use so much that a global config makes sense for you, why not wrap this into your own directive?

<for-against-toggle-switch ng-model="ctrl.model.side" />
zachlysobey commented 9 years ago

I too think this would be a very useful enhancement. Personally I don't know if my angular chops are good enough that I could successfully wrap in my own directive without a $watch function for each instance.

sean-hill commented 8 years ago

I agree, I'm converting my checkboxes in my app to this toggle and on one of them I have ng-true-value="false" ng-false-value="true" for a specific case.

sean-hill commented 8 years ago

Just made a pull request here.