遇到一些麻煩縮小和AngularJS ;-(AngularJS服務配置價值被摧毀的微小
我發現HTTP請求這個jsfiddle「加載」擴展,通過AngularJS Wiki頁面。
這真是棒極了。直到我刊登出來,並縮小破壞它 我不能找到一種方法,使用「注入」的配置,所以IM有點失去了做什麼
原始代碼:
angular.module("app.services", []).config(function($httpProvider) {
var spinnerFunction;
$httpProvider.responseInterceptors.push("myHttpInterceptor");
spinnerFunction = function(data, headersGetter) {
$("#loader").show();
return data;
};
return $httpProvider.defaults.transformRequest.push(spinnerFunction);
}).factory("myHttpInterceptor", function($q, $window) {
return function(promise) {
return promise.then((function(response) {
$("#loader").hide();
return response;
}), function(response) {
$("#loader").hide();
return $q.reject(response);
});
};
});
精縮代碼:
angular.module("app.services", []).config(function (a) {
var b;
a.responseInterceptors.push("myHttpInterceptor");
b = function (d, c) {
$("#loader").show();
return d
};
return a.defaults.transformRequest.push(b)
}).factory("myHttpInterceptor", function (a, b) {
return function (c) {
return c.then((function (d) {
$("#loader").hide();
return d
}), function (d) {
$("#loader").hide();
return a.reject(d)
})
}
});
會拋出以下錯誤: 錯誤:未知提供商:一個從app.services
只是澄清,它實際上被稱爲「內聯註釋」。 – 2013-03-11 15:39:32
是的,已更正。 – Stewie 2013-03-11 15:44:10
感謝您的建議;-) 我得到以下錯誤,使用您編寫的代碼'未捕獲的錯誤:未知的提供者:myHttpInterceptorProvider < - myHttpInterceptor < - $ http < - $ compile'得到了什麼錯誤是由什麼引起的? – 2013-03-11 16:00:00