В угловом режиме существует функция $ q, которая может быть введена в директивы, контроллеры и т. Д., Что является близким внедрением Q. Криса Коваля. Таким образом, внутри функции then вместо возврата значения или чего-то еще, что было бы прикован к следующему "thenable" функции, просто возвращают $q.reject('reject reason');
Пример:
angular.module('myQmodule',[])
.controller('exController',['$q',function($q){
//here we suppose that we have a promise-like function promiseFunction()
promiseFunction().then(function(result1){
//do the check we want in order to end chain
if (endChainCheck) {
return $q.reject('give a reason');
}
return;
})
.then(function(){
//this will never be entered if we return the rejected $q
})
.catch(function(error){
//this will be entered if we returned the rejected $q with error = 'give a reason'
});
}]);