$resource callback (error and success)

前端 未结 3 922
梦谈多话
梦谈多话 2020-12-02 20:16

I´m using AngularJS 1.1.3 to use the new $resource with promises...

How can I get the callback from that? I tried the same way I did with $http :

$re         


        
3条回答
  •  一整个雨季
    2020-12-02 20:47

    Two ways

    var resource = $resource("");
    resource.$promise.then(function(data){
    // do stuff success
    }, function(error){
    //do stuff error
    });
    

    Other way

    var resource = $resource("");
    resource({}, function success(data){
    //do stuff
    }, function error(error){
    //do stuff
    }
    

提交回复
热议问题