我有資料表,當我選擇一個單選按鈕時,整個表行都會被選中。下面是我的代碼

期待:
當我選擇單選按鈕時,它不應該選擇表格行。 演示 有人可以幫助我嗎
<md-data-table-container>
<table md-data-table md-row-select="testConfig.selected">
<thead md-trim-column-names md-order="testConfig.order">
<tr>
<th order-by="name">Report Name</th>
<th numeric order-by="views.value">Visits</th>
<th numeric order-by="users.value">Unique Users</th>
<th>Users</th>
</tr>
</thead>
<tbody md-auto-select>
<tr ng-repeat="report in test_data | orderBy: testConfig.order">
<td>{{report.name}}</td>
<td>{{report.views.value}}</td>
<td>{{report.users.value}}</td>
<td>
<ul>
<li ng-repeat="person in people">
<label>
<input type="radio" ng-model="$parent.name" name="name" value="{{person.name}}" required />{{person.name}}
</label>
</li>
</ul>
</td>
</tr>
</tbody>
</table>
</md-data-table-container>
uj5u.com熱心網友回復:
在單選按鈕上使用Event.stopPropagationlabel,以防止click事件傳播到表行:
<md-data-table-container>
<table md-data-table md-row-select="testConfig.selected">
<thead md-trim-column-names md-order="testConfig.order">
<tr>
<th order-by="name">Report Name</th>
<th numeric order-by="views.value">Visits</th>
<th numeric order-by="users.value">Unique Users</th>
<th>Users</th>
</tr>
</thead>
<tbody md-auto-select>
<tr ng-repeat="report in test_data | orderBy: testConfig.order">
<td>{{report.name}}</td>
<td>{{report.views.value}}</td>
<td>{{report.users.value}}</td>
<td>
<ul>
<li ng-repeat="person in people">
<label ng-click="$event.stopPropagation()">
<input type="radio" ng-model="$parent.name" name="name" value="{{person.name}}" required />{{person.name}}
</label>
</li>
</ul>
</td>
</tr>
</tbody>
</table>
</md-data-table-container>
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/520421.html
