使用AngularJS 1.2如何從http攔截器進行廣播?
我的截擊看起來是這樣的:
$httpProvider.interceptors.push(['$q', '$log', '$rootScope', function ($q, $log, $rootScope) {
return {
'request': function(config) {
$rootScope.$broadcast('spin');
console.info('request!');
return config || $q.when(config);
},
...
在我的導航控制器(用來處理和裝載/微調結合的觀點):
$rootScope.$watch('spin', function(event) {
console.info('spin');
$scope.spinner++;
});
廣播似乎儘管我可以看到很多請求,但在收到的所有回覆結束時只發生一次!在控制檯日誌中輸入。
我該如何管理我的全局微調器/加載器?
編輯 我希望在加載數據時在導航欄中顯示加載器/微調器。
你想使用這個 –
@Ajaybeniwal編輯要達到什麼:目的添加 – Tjorriemorrie