$http.post(serviceBase + 'aaaa', data, config)
.success(function (data, status, headers, config) {
$scope.PostDataResponse = data;
$scope.messages = ['Success'];
}, startTimer())
.error(function (data, status, header, config) {
var messages = [];
angular.forEach(data.errors, function (value, key) {
$scope.ResponseDetails = "Data: " + data +
"<hr />status: " + status +
"<hr />headers: " + header +
"<hr />config: " + config;
messages.push('Error! ' + key + ' is not correct');
});
$scope.messages = messages;
});
// expose dependencies on this
};
var startTimer = function () {
var timer = $timeout(function () {
$timeout.cancel(timer);
$location.path('/klupe');
}, 3000);
};
但是计时器不工作,如果我是console.log $ location.path,没关系,但是函数startTimer()没有调用。日Thnx
答案 0 :(得分:1)
将函数调用放在成功块内,而不是第二个参数