我正在用angularJs
建造laravel 5.1
.
当用户点击一个按钮时,我想发送一个destroy request
以将其从数据库中删除,然后在完成后发送一个get request
以获取新数据,因为其中一个已被删除.
So I attached my method to an ng-click event on a button, this works, it hits the method.
I then run a .destroy request
. Inside the .then()
method of that .destroy
I want to then call another method which has a .get request
.
这在Safari中非常有效,但在Chrome或Firefox中不起作用.
Here is my code for the controller
, the method that is called on button click to delete is deleteOpportunity()
:
$scope.getOpportunities = function()
{
UBOService.get()
.then(function successCallback(responsed) {
$scope.opportunities = responsed.data;
}, function errorCallback(response) {
$scope.error = response;
});
}
$scope.deleteOpportunity = function()
{
UBOService.destroy($scope.activeItem.id)
.then(function successCallback(response) {
$scope.getOpportunities();
return false;
}, function errorCallback(response) {
$scope.error = response;
});
}
My service code:
app.service('UBOService', function($http) {
return {
get : function() {
return $http.get('/api/user-booked-opportunities');
},
destroy : function(id) {
return $http.delete('/api/user-booked-opportunities/' + id);
}
}
})
Am I doing something wrong? Is there something I am missing? How does Safari interact differently with this code which makes it work?