Tôi có ứng dụng góc với danh sách các mục. Tôi đang cố triển khai phương thức "Xác nhận xóa" tùy chỉnh, để khi người dùng nhấp vào nút "Xóa" bên cạnh một mục, phương thức được mở để xác nhận xóa. Khi nhấp vào "Có", một hàm deleteItem() được kích hoạt. Vấn đề của tôi là máy chủ trả về 404 không tìm thấy cho yêu cầu xóa. Nó hoạt động khi tôi sử dụng hộp thoại xác nhận jquery tiêu chuẩn, vì vậy tôi đoán ID mục không được chuyển qua phương thức cho hàm xóa. có ai giúp được không?Xóa tùy chỉnh xác nhận trong angularJS
<div class="span6">
<table class="table table-striped table-condensed">
<thead>
<tr>
<th style="min-width: 80px;">Name:</th>
<th style="width:20px;"> </th>
<th style="width:20px;"> </th>
</tr>
</thead>
<tbody>
<tr ng-repeat="item in items | filter:query | orderBy:orderProp">
<td>{{ item.name }}</td>
<td><a ng-click="editItem(item.id)" class="btn btn-small btn-primary">Edit</a></td>
<td><a ng-click="openModal(item.id)" class="btn btn-small btn-success">Delete</a></td>
</tr>
</tbody>
</table>
<modal-dialog show='modalShown' id = "itemModal" width='300px' height='40%'>
<p>Are you sure you want to delete this item?<p>
<button ng-click = "deleteItem(item.id)" class = "link">Yes</button>
</modal-dialog>
</div>
Dưới đây là bộ điều khiển:
angular.module('myApp.controllers')
.controller('ItemCtrl', ['$scope', 'ItemsFactory', 'ItemFactory', '$location', '$route',
function ($scope, ItemsFactory, ItemFactory, $location, $route) {
$scope.modalShown = false;
//callback for ng-click 'deleteItem':
$scope.openModal = function (itemId) {
$scope.modalShown = !$scope.modalShown;
};
//callback for ng-click 'deleteItem':
$scope.deleteItem = function (itemId) {
ItemFactory.delete({ id: itemId }).$promise.then(function (items){
$scope.items = items;
$location.path('/items');
$route.reload();
}, function (err) {
console.error(err);
});
// }
};
http://stackoverflow.com/questions/29602222/create-a-simple-bootstrap-yes-no-confirmation -or-just-notification-alert-in-angu/37265529 # 37265529 –