Here's the workflow:
On the user account page, the entire object belonging to this user must be indicated.
Next to each object is the “delete” button, which opens the Bootstrap modality. The modal asks the user if he really wants to delete the object, and if they confirm, then the modal must leave, the object must be deleted, and the view must be updated to reflect the deletion.
I reject the modal attribute data-dismisson the confirmation button inside the modal file.
Here is a function of my controller that deletes an object and (should) update the view:
$scope.deleteObject = function(object) {
object.destroy({
success: function(object) {
$scope.$apply();
},
error: function(object, error) {
}
});
};
However, I need to refresh the page to view the updated view with the deleted object.
$scope.$apply?
EDIT: , $scope . ( - .
, :
.controller('AccountCtrl', function($scope) {
var query = new Query('Object');
query.find().then(function(objects) {
$scope.objects = objects;
});
$scope.deleteObject = function(object) {
object.destroy({
success: function(object) {
}
});
}
});
find $scope, :
.controller('AccountCtrl', function($scope) {
$scope.getObjects = function() {
var query = new Query('Object');
query.find().then(function(objects) {
$scope.objects = objects;
});
}
$scope.getObjects();
$scope.deleteObject = function(object) {
object.destroy({
success: function(object) {
$scope.getObjects();
}
});
}
});
, , , .