简体   繁体   中英

angular js radio buttons display and print

I'm trying to modify the following code so the input element idEcho prints the value of the radio button being clicked, and instead of the current label display, i want to show W1, W2, W3 and W4 correspondingly. and i want the values returned by the clicked radio buttons to be N1, N2, N3 and N4.

<body>
<label ng‐repeat="w in radioDetails">
  {{w.what}}:
  <input type="radio" ng‐model="$parent.mSelection" value={{w.what}}><br>
</label>
<input id="idEcho" type="text">

<script>
  myModule=angular.module("appEX",[]);
  myModule.controller("ctrl", function($scope){   
    $scope.mSelection="a1";
    $scope.radioDetails=[
      {what:"a1",yes:"W1",no:"N1"},
      {what:"a2",yes:"W2",no:"N2"},
      {what:"a3",yes:"W3",no:"N3"},
      {what:"a4",yes:"W4",no:"N4"}
    ];
  });
</script>
    <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
</body>

all that assuming proper angular js setup thanks

<label ng‐repeat="w in radioDetails">
  {{w.yes}}:
  <input type="radio" ng‐model="$parent.mSelection" value={{w.no}}><br>
</label>
<input id="idEcho" type="text" ng‐model="$parent.mSelection">

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM