app.config(function(RestangularProvider) {
RestangularProvider.addRequestInterceptor(function(element) {
console.log("Request started");
return element;
});
RestangularProvider.addResponseInterceptor(function(data) {
console.log("Request returned");
return data;
});
});我正在努力弄清楚如何创建一个旋转器,以便在请求发生时使用。我怀疑这通常是通过在请求启动时显示并在请求完成时隐藏它来完成的。
我怎么才能用棱角和右旋做这件事?我已经设置了上述拦截器,但这是在.conifg()中,所以我不能访问$rootScope或任何东西来跟踪任何div的可见性。
发布于 2014-06-09 14:04:33
结果是,我可以在run()块内部配置Restangular,这样就可以访问$rootscope:
app.run(function($rootScope, Restangular) {
Restangular.addRequestInterceptor(function(element) {
$rootScope.xhr = true;
return element;
});
Restangular.addResponseInterceptor(function(data) {
$rootScope.xhr = false;
return data;
});
});https://stackoverflow.com/questions/24088610
复制相似问题