【发布时间】:2016-08-01 10:36:49
【问题描述】:
我的代码遇到问题,我不明白它出了什么问题..
有趣的是,api 调用得很好,但它没有进入success 函数
orders.pay(ss($scope.ss, $scope.oo))
.success(function (data) {
angular.module('services.orders', ['users.service'])
.factory('orders', ['$http', 'user', '$q', function ($http, user, $q) {
'use strict';
function genericSuccess (res) {
return res.data.data; // yes, really.
}
function pay (payment) {
return $http.post('v1/payment/authorize', payment)
.then(genericSuccess);
}
orders.pay(ss($scope.ss, $scope.oo))
.success(function (data) {
//It should called success either it should gone to error but it says
//Error:orders.pay(...).success is not a function
//can any one suggest how to solve it
notify.message('Thank you!');
}).error(function (data) {
notify.message('Error: ' + data.data.message);
});
【问题讨论】:
-
orders函数是什么样的?如果可以,请发布它。 -
.success和.error已被弃用,即使这不是您的问题的原因,您也应该避免使用它们。请改用.then和.catch。
标签: angularjs