问题是,当服务器返回404或401时,微调器($ ionicLoading)永远不会隐藏。
我找到了一个隐藏微调器的.js文件,如果发生错误或类似名称" spinner.js"
spinner.js
(function() {
'use strict';
angular
.module('restaurant')
.config(function($httpProvider) {
$httpProvider.interceptors.push(function($rootScope, $q) {
return {
request: function(config) {
$rootScope.$broadcast('loading:show');
return config;
},
response: function(response) {
$rootScope.$broadcast('loading:hide');
return response;
},
requestError: function(rejectReason) {
debugger;
$rootScope.$broadcast('loading:hide');
return $q.reject(rejectReason);
}
};
});
})
.run(function($rootScope, $ionicLoading) {
$rootScope.$on('loading:show', function() {
$ionicLoading.show({});
});
$rootScope.$on('loading:hide', function() {
debugger;
$ionicLoading.hide();
});
});
})();
我把一些调试器放到这个脚本中,但是当我向服务器请求数据时从未调用过。如何将此脚本集成到我的控制器中?或者我必须将它放入app.js?
谢谢!
答案 0 :(得分:0)
您的代码中似乎缺少def findNumbers(str):
found1 = False
found2 = False
i = 0
while not found1 and i<len(str):
if str[i] in "0123456789":
found1 = True
else:
i = i + 1
if found1:
j = 0
while not found2 and j<len(str):
if str[j] in "0123456789":
found2 = False
else:
j = j + 1
else:
return 0
istr = str[i:j]
n = (istr)
return n
print (findNumbers("Maroon 5"))
。来自服务器的import os
from itertools import groupby
from operator import itemgetter
SEARCH_PATH = "E:\\project\\elohim\\"
all_files = []
for root, dirs, files in os.walk(SEARCH_PATH):
for file in files:
relativePath = os.path.relpath(root, SEARCH_PATH)
if relativePath == ".":
relativePath = ""
all_files.append(
(relativePath.count(os.path.sep),
relativePath,
file
)
)
all_files.sort(reverse=True)
for (count, folder), files in groupby(all_files, itemgetter(0, 1)):
print('Directory:', folder)
for file in files:
print('File:', file[2])
和groupby
返回itertools
作为responseError。
responseError