JSFiddle - React, Tailwind, and code Playground
HTML
<div ng-app="test" ng-controller="test">
</div>
JavaScript
angular.module('test', [])
.controller('test', function($scope, $http) {
console.log('Running before then');
beforeThen();
console.log('Running after then');
afterThen();
//The exception thrown in 'afterThen' halts execution. Comment it out then un-comment this to run.
//console.log('Forced error after');
//errorAfter();
function errorAfter () {
$http.get('/echo/jsonblaaaaaa')
.catch(function(e) {
console.log('BEFORE: catch')
throw e;
})
.error(function(d) {
console.log('BEFORE: error', d);
});
}
function beforeThen() {
$http.get('/echo/json')
.success(function(d) {
console.log('BEFORE: success')
return d;
})
.then(function(d) {
console.log('BEFORE: hit', d);
});
}
function afterThen() {
$http.get('/echo/json')
.then(function(d) {
console.log('AFTER: hit')
return d;
}).success(function(d) {
console.log('AFTER: success')
});
}
});