Angularjs radio buttons

后端 未结 2 1204
余生分开走
余生分开走 2020-12-14 15:19

I know that this has been spoken about in some Google Threads but I still can\'t find the right solution to bind my radio inputs to a model (in clean\'n simple manner),

相关标签:
2条回答
  • 2020-12-14 15:49

    What has worked for me is to set the model variable to { } and that will reset the radio buttons to their default (not selected) state. Of course, this will only work if you have your radio button tags correct as in tosh's answer.

    In your case:

    $scope.searchBy = { };
    
    0 讨论(0)
  • 2020-12-14 16:01

    I think you should use same variable with different values in those two radio buttons.

    <input ng-model="searchBy" value="Rma" type="radio" name="search-type">
    <input ng-model="searchBy" value="Delivery" type="radio" name="search-type">
    

    Then, you should have searchBy set either "Rma" or "Delivery" depending on user input.

    0 讨论(0)
提交回复
热议问题