2015-12-02 74 views
0

作为标题,我需要选择第一个单选按钮作为ng-repeat中的默认值。默认值单选按钮转换为ng-repeat angularjs

<div class="customRadio" ng-repeat="item in fundSwitch.compatibleFund track by $index"> 

    <ion-radio name="rifFondo" ng-model="dispositive.request.rifFondo" ng-value="item.codiceIsin" ng-checked="$first"> 
    <h3>{{item.descrizioneFondo}} {{$index}}</h3> 
    <p><strong>Data valorizzazione :</strong> {{item.dataQuotazione}}</p> 
    </ion-radio> 
</div> 

我尝试了其他条件到ng检查:ng-checked =“$ index == 0”,但它没有工作。

+0

我不认为ng-checked和ng-model应该一起使用。 https://docs.angularjs.org/api/ng/directive/ngChecked 如何初始化item.codiceIsin的值到数组中的第一个元素? –

+0

我不能因为item.codiceIsin的值是从服务器的响应动态分配的。 –

+0

抱歉,意味着rifFondo的价值 - 不确定这对您的答案是否有影响。 –

回答

0

我解决它指定数组的第一个值作为建议我:

$scope.fundSwitch.compatibleFund = FundService.extractFundSwitchParams(data)['fondiCompatibili']; 
    $scope.dispositive.request.rifFondo = $scope.fundSwitch.compatibleFund[0].codiceIsin; 

感谢您的帮助。