我是新角色,我想要獲取特定行的索引來執行函數hidestuff()
,我將item.id
傳遞給該函數並我想隱藏行女巫包含此ID ..但我怎麼傳遞行索引刪除整個行?在ng-repeat中獲取行索引(或id)在特定行上執行某些操作
HTML:
<tr ng-repeat="item in ItemsByPage[currentPage]">
<td>
<div ng-model="tid"
ng-hide="hidden"
ng-class="{fade: startFade}">
{{item.id}}
</div>
</td>
<td>
<div editable-text="item.name"
onaftersave='inlineupdateName(item.id,item.name)'
ng-model="tname" data-n='item.name'>
{{item.name}}
</div>
</td>
<td>
<div editable-text="item.phone"
onaftersave='inlineupdatephone(item.id,item.phone)'
ng-model="tphone">
{{item.phone}}
</div>
</td>
</tr>
<input type="text" ng-model="delId" class="form-control"
placeholder="Enter user id to delete th user">
<button ng-click="deleteuser(delId)" type="button"
class="btn btn-primary">
Delete User
</button>
JS:
$scope.hideStuff = function (delId) {
$scope.startFade = true;
//here i want to use the index to delete the row
$scope.hidden = true;
};
$scope.deleteuser = function (dalId) {
var data = {delId : $scope.delId};
$http.post('delete.php', data)
.success(function(response) {
$scope.hideStuff(delId);
});
};
您可以用$指數看文檔https://docs.angularjs.org/api/ng/directive/ngRepeat – Overmachine
@Overmachine我讀它,得到的指數,但如何獲得在控制器中的函數中使用'delId'的索引 –