2016-09-30 9 views
0

ng-repeatで複数のラジオ入力オプションを作成しようとしていますが、エレメントが作成されているときに一意のID I ("id":"1", "id":"2" or "id":"3")の代わりに、すべてが特に'fee[{{ record.id }}]'という名前になっています。これにより、最終的なラジオセットのみがチェックされます。私はここで何が欠けていますか?複数のラジオボタンセットを作成する角度ng-repeat

HTML:

<div ng-app="app" ng-controller="fee_control"> 
    <div ng-repeat="record in fees" > 
    {{ record.description }} : 
    <input type="text" value="{{ record.amount }}"> 
    Active: 
    <input type="radio" name="fee[{{ record.id }}]" value="{{ record.amount }}" checked /> 
    Inactive: 
    <input type="radio" name="fee[{{ record.id }}]" value="0" /> 
    </div> 
</div> 

Javascriptを:

var app = angular.module('app', []); 
    app.controller('fee_control', function($scope) { 
    $scope.fees = [ 
        {"id":"1","amount":"5.00","description":"Approved"}, 
        {"id":"2","amount":"2.00","description":"Authorized"}, 
        {"id":"3","amount":"2.00","description":"Settled"} 
        ]; 
    }); 

答えて

1

この

<div ng-repeat="record in fees" > 
    {{ record.description }} : 
    <input type="text" value="{{ record.amount }}"> 
    Active: 
    <input type="radio" name="fee[{{ record.id }}]" value="{{record.amount }}" ng-checked="true" /> 
    Inactive: 
    <input type="radio" name="fee[{{ record.id }}]" value="0" /> 
</div> 

利用NG-確認代わりのおかげ

+0

作品、感謝:)にチェックしてみてください! – Calvin

関連する問題