auto switch toggle off if one is currently on

后端 未结 2 535
栀梦
栀梦 2020-12-22 13:02

there are nested toggle buttons which are off by default, when user turns one on it saves a value to localstorage. What i want to do is when one is turned on and you try to

2条回答
  •  孤城傲影
    2020-12-22 13:58

    note: You've edited your question enough that my prior answer isn't valid in any way.

    Your toggle UX can easily be addressed with Angular's native input[radio] implementation. You need to simply define two inputs using both ngModel and ngValue on each input:

    
    
    
    

    You can also use ng-change to trigger the active_shop function:

    
    

    codepen example

    The other option is to utilize ui.bootstrap's radio button implementation (if you're indeed using Bootstrap to style your app.

提交回复
热议问题