Radio buttons plus a text field in Angular.js

前端 未结 2 1114
有刺的猬
有刺的猬 2021-01-19 04:44

Using AngularJS, I would like to create a list of options with radio buttons, the last of which has an empty text field labeled \'Other\' for inputing an option that is not

2条回答
  •  刺人心
    刺人心 (楼主)
    2021-01-19 05:30

    I made some very small modifications to your pen HERE.

    The short of it is, instead of having 'Other' as a value, i made it a blank option, with the input actually controlling the value.

    $scope.colors = [
          "Red",
          "Green",
          "Blue",
          ""
         ];
    

    html:

      
      
    

    This allows the input to actually control the value of 'Other'...

提交回复
热议问题