我有問題。之前沒有找到答案,或者它不是我的問題。如何計算選中的複選框(不在項目組中)
我正在構建靜態應用程序,我需要在頁面上有這樣的表格。 (他們只是在綁定的角...我在它新的,我已經卡住了。
<table class="table table-responsive table-striped">
<thead>
<tr>
<th class="text-center"></th>
<th class="text-center">1st</th>
<th class="text-center">2nd</th>
<th class="text-center">3rd</th>
<th class="text-center">4th</th>
<th class="text-center">5th</th>
<th class="text-center">6th</th>
</tr>
</thead>
<tbody>
<tr>
<td>First header</td>
<td class="text-center"><input type="checkbox" ng-model="myModel.myData[1].attribute1" /></td>
<td class="text-center"><input type="checkbox" ng-model="myModel.myData[1].attribute2" /></td>
<td class="text-center"><input type="checkbox" ng-model="myModel.myData[1].attribute3" /></td>
<td class="text-center"><input type="checkbox" ng-model="myModel.myData[2].attribute1" /></td>
<td class="text-center"><input type="checkbox" ng-model="myModel.myData[2].attribute2" /></td>
<td class="text-center"><input type="checkbox" ng-model="myModel.myData[2].attribute3" /></td>
</tr>
而且它更進了一步......(即myModel.myData [3](3個屬性) ,myModel.myData [4](3個屬性),myModel.myData [5](3個屬性))
現在......我都數不過來:
- 多少attributes1(與全myModel.MyData [1到N])被選中
- 多少屬性2(與整個myModel.MyData [1到N])被選中
- 等等...
我現在所得到的,我可以accces的值,方法是:{{myModel.myData [1] .attribute1}} 但它返回我真/假(這很好) - 但在控制器中無法訪問到這一點。 (我的控制器js文件幾乎是清晰的,所以我不把它放在這裏)
如果some1可以幫助我,我可以在哪裏搜索解決方案我會很感激。
在控制器,你可以創建{attributrType,計數}通過循環遍歷數組myModel.myData和檢查複選框的狀態。 – Kanti