我有以下html模板:
<div ng-app ng-controller="Ctrl">
<div class="cont">
<table>
<tr><th ng-repeat="column in columns">{{column}}</th></tr>
<tr ng-repeat="(i, row) in people">
<td ng-repeat="(j, column) in columns">
<input type="radio" name="select" ng-if="column === 'id'">
<span>{{row[column]}}</span>
</td>
</tr>
</table>
</div>
</div>
然后我定義我的 Ctrl 如下
function Ctrl($scope) {
$scope.selectedId = 'aaaaa';
$scope.columns = ['id','name', 'age'];
$scope.people=[
{
'id':'aaaaa', 'name':'rachit', 'age':11
},
{
'id':'bbbbb', 'name':'gulati', 'age':12
},
{
'id':'ccccc', 'name':'rocks', 'age': 13
}
]
}
https://jsfiddle.net/en91zuxb/
它顯示所有專案的單選輸入,而我的意圖是僅在第一列上顯示單選按鈕,因為第一列是id
列... ...
uj5u.com熱心網友回復:
看來您的角度版本很舊,這是與 angularjs < 1.2 相關的錯誤。嘗試升級您的 angularjs 版本或使用 ng-show 代替。
以下代碼對我有用。
<input type="radio" name="select" ng-show="column == 'id' ">
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/497711.html
標籤:angularjs 单选按钮 angularjs-ng-重复 角度ng-if