您可以利用angular提供的索引。這裏是我的代碼怎麼辦
的html代碼:
<body ng-controller="MainCtrl">
<p>Hello {{name}}!</p>
<div ng-repeat="app in apps" ng-init="index1 = $index">
{{app.proj}}
<span ng-repeat="tc in typeCodes" ng-init="index2 = $index">
<input type="radio" name="app_{{index1}}" ng-model="app.selectedCode" value={{tc.key}}
ng-change="selectionChanged(index1, app.selectedCode)">{{tc.key}}
</span>
<div>
<span ng-repeat="subApp in app.subApps" ng-init="index3 = $index">
{{subApp.appName}}-
<span ng-repeat="tc in typeCodes" ng-init="index4 = $index">
<input type="radio" name="tc_{{index1}}_{{index3}}" ng-model="subApp.type" ng-value="{{tc.key}}"
ng-checked="subApp.type === tc.key"
ng-change="subAppSelection(index1, index3, tc.key)">{{tc.key}}
</span><br>
</span>
</div><br><br>
</div>
控制器代碼:
$scope.selectionChanged = function (ind, type) {
for (var j = 0; j < $scope.apps[ind].subApps.length; j++) {
$scope.apps[ind].subApps[j].type = type;
}
}
$scope.subAppSelection = function (ind1, ind2, type) {
$scope.apps[ind1].subApps[ind2].type = type;
}
plunker不能正常工作,需要對這個問題更清晰 –
@SrikanthB編輯問題和闖入者現在正在工作 – Praveen