AngularJS: Comment gérer le succès et erreur rappels avec ngResource?

La docs ne donne aucune idée à ce sujet.

Mon REST enpoint pourraient jeter l'erreur

$scope.delete = function(index) {
    Transaction.delete({transactionId: $scope.transactions[index].uuid})     
  };

J'ai changé le ci-dessus pour la suite

$scope.delete = function(index) {
    Transaction.delete({transactionId: $scope.transactions[index].uuid})
      .success('transaction deleted');
  };

Mais il ne parvient pas

TypeError: Object #<Resource> has no method 'success'
    at Object.TransactionController.$scope.delete (http://localhost:5000/static/app/js/controllers/transactionController.js:26:8)
    at http://localhost:5000/static/app/lib/angular/angular.js:6094:36

Comment puis-je gérer success et error scénarios?

P. S. je suis nouveau sur le JavaScript

  • essayez d'ajouter une fonction de rappel à la delete l'invocation de méthode, et voir si cela fonctionne.
InformationsquelleAutor daydreamer | 2013-05-16