Reputation: 187
i have modal box. I want submit form, show success message, and after 3 sec, close modal box. Here is my ctrl
$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);
};
But timer not working, if i console.log $location.path, it's ok, but function startTimer() is not calling. Thnx
Upvotes: 0
Views: 156
Reputation: 962
Put the function call inside the success block, not as a second paramter
Upvotes: 1