After my $http.post method has completed, I want to initiate my $http.get method. To achieve this, I have created a controller that triggers upon clicking a button.
var app = angular.module("loginApp", []);
app.controller("ctrlLogin", function($scope, $http, $window, $timeout){
$scope.name = "";
$scope.key = "";
var message = {name: $scope.name, key: $scope.key};
$scope.setData = function(){
message.name = $scope.name;
message.key = $scope.key;
$http.post('/getData', message)
.then(function() {
console.log("msg sent");
}, function error() {
console.log("msg failed");
}).then(
$http.get('/doLogon')
.then(function() {
console.log("logon");
}, function error() {
console.log("doLogon failed");
}));
};
});
Currently, "logon" is displayed before "msg sent". I require both functions to be executed simultaneously when the same button is clicked.