当用户使用复选框选项选择一行并点击“计算折旧”时,我想要获取{{asset.purchaseValue}},{{asset.residualValue}},{{asset.purchaseDate}}和{{asset.ddate}}执行计算以发送回用户。我如何在jQuery,AngularJS或vanilla Javascript中获得这些值?如何从选定的表格行中获取值?
<table align="center" class="assetlist">
<thead>
<tr>
<th width="45px">
<select ng-model="sortBy" class="localSearch">
<option value="title">Title</option>
<option value="ddate">Disposal Date</option>
<option value="date">Purchase Date</option>
<option value="residualValue">Residual Value</option>
<option value="purchaseValue">Purchase Value</option>
</select>
</th>
<th class="thead" ng-hide="hide"><input type="text" class="localSearch" placeholder="Title" ng-model="searchString.title" /></th>
<th class="thead" ng-hide="hide"><input type="text" class="localSearch" placeholder="Purchase Date" ng-model="searchString.date" /></th>
<th class="thead" ng-hide="hide"><input type="text" class="localSearch" placeholder="Purchase Value" ng-model="searchString.purchaseValue" /></th>
<th class="thead" ng-hide="hide"><input type="text" class="localSearch" placeholder="Disposal Date" ng-model="searchString.ddate" /></th>
<th class="thead" ng-hide="hide"><input type="text" class="localSearch" placeholder="Residual Value" ng-model="searchString.residualValue" /></th>
</tr>
</thead>
<tbody>
<tr ng-repeat="asset in assets | orderBy:sortBy | filter:searchString : searchStrict | limitTo: rowLimit">
<td><input type="checkbox" ng-model="checked"/></td>
<td>{{asset.title}}</td>
<td>{{asset.date | date: "MMMM d, y"}}</td>
<td>{{asset.purchaseValue | currency:"£"}}</td>
<td>{{asset.ddate | date: "MMMM d, y"}}</td>
<td>{{asset.residualValue | currency:"£"}}</td>
</tr>
</tbody>
</table>
<button class="formbtn" ng-disabled="!checked">Calculate Depreciation</button>
使用'NG-click' – charlietfl
看看我的回答如下传递整个对象到一个函数。让我知道如果这有帮助! :) –
你可以看到我的答案更新。 – Sajal