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

Possible to change switch values?

Open rbarman opened this issue 10 years ago • 4 comments

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?

rbarman avatar Sep 27 '15 22:09 rbarman

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" />

cgarvis avatar Sep 28 '15 14:09 cgarvis

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.

zachlysobey avatar Oct 15 '15 19:10 zachlysobey

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 avatar Feb 02 '16 19:02 sean-hill

Just made a pull request here.

sean-hill avatar Feb 02 '16 19:02 sean-hill