2
AngularJS 응답 오류 인터셉터에서 현재 요청이 시작된 범위를 검색 할 수있는 방법이 있습니까?요청이 인터셉터에서 생성 된 범위 가져 오기
module.controller('myController', function($http, $scope) {
$scope.getData = function() {
// This scope is which the request is originated
$http.get('http://www.example.com/get', {
params: { 'id': '1234' }
}).success(function(data, status, headers, config) {
// ...
}).error(function(data, status, headers, config) {
// ...
});
}
});
module.factory('myInterceptor', function($q) {
return {
'responseError': function(response) {
// How can I get the scope of 'myController' here?
return $q.reject(response);
}
};
});
은'params' 객체가 오른쪽 GET' 요청 '에 쿼리 문자열로 해석됩니다? 'scope'를'params' 객체에 전달하는 것이 합리적입니까? –
요청을 실제로 –
이상으로 보내기 전에 config.params.origScope를 삭제할 수 있다고 생각했습니다. 기본적으로 말했듯이 공장이나 서비스까지 범위를 전달하는 것은 좋은 디자인이 아닙니다. –