AngularJS required radio buttons needs two click events to be valid

前端 未结 8 2015
庸人自扰
庸人自扰 2020-12-15 19:43

I have a very simple form where a radio button is required to be selected in order for a form to be valid. The radio buttons are generated by ngRepeat.

8条回答
  •  伪装坚强ぢ
    2020-12-15 20:14

    The reason why this is breaking - is because you're setting all radio boxes to be required. As a result, depending on how you write it - angularjs is saying it's invalid because not all have been selected at some point.

    The way around this is to do something like the following:

    Using checkboxes and required with AngularJS

    (check the 1st and 2nd answers). This will resolve your problem.

提交回复
热议问题