2016-10-18 35 views
0

我试图修改下面的代码,所以输入元素idEcho打印被单击的单选按钮的值,而不是当前的标签显示,我想显示W1,W2, W3和W4。 ,我希望单击单选按钮返回的值为N1,N2,N3和N4。角度js单选按钮显示和打印

<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> 

所有假设角适当设定JS感谢

回答

0
<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">