如何定义何时显示或不显示加载屏幕
How to define when show or not a loading screen
所以,我有一个应用程序,它在加载一些ajax请求时使用此代码在所有屏幕内容上显示和隐藏加载屏幕。
app.config( function( $stateProvider, $urlRouterProvider, $httpProvider )
{
$httpProvider.interceptors.push(function( $rootScope )
{
return {
request: function(config) {
$rootScope.$broadcast('loading:show')
return config
},
response: function(response) {
$rootScope.$broadcast('loading:hide')
return response
}
}
});
})
.run(function( $state, $rootScope, $ionicLoading, $storage )
{
$rootScope.$on('loading:show', function()
{
$ionicLoading.show({template: 'Loading'});
});
$rootScope.$on('loading:hide', function()
{
$ionicLoading.hide();
});
});
当我想加载我使用的东西时:
$http.post( "http://myexample.com.br/json-data", {param1:"1"} ).then(function(result){});
问题是,在某些情况下,我希望在后台加载某些内容而不显示加载屏幕。
使用拦截器设置它的方式,这些加载事件将在每次$http
调用时引发。我建议从$rootScope
中删除事件侦听器,并仅将它们应用于您希望加载屏幕显示的单个控制器范围。
我把$ionicLoading.hide();
放在$http.post
之后。不是最好的,但要解决。
$http.post( "http://myexample.com.br/json-data", {param1:"1"}).then(function(result)
{
});
$ionicLoading.hide();
相关文章:
- 如何在生成下载文件时显示加载动画
- 如何在谷歌字体加载时显示加载图像
- 现在可以在加载addThis时显示加载吗
- 单击时选择2(未选中),显示加载微调器javascript
- 如何在网页加载时显示加载内容,并在页面完全加载时隐藏此内容
- 在弹出窗口中显示加载消息
- 使用jquery/ajax显示加载图像
- 在引导轮播加载之前显示加载微调器
- 是否可以在页面开始加载之前显示加载gif/image
- 单击链接后显示加载程序
- 等待数据时显示加载程序
- 在谷歌地图上显示加载消息
- 只想在页面上未加载初始数据时显示加载gif
- 如何在加载选项卡内容时显示加载图像
- 如何在ajax请求中显示加载微调器
- 当javascript图像转盘加载36个图像时,我可以显示加载指示器吗
- 隐藏/显示加载功能不起作用
- Jquery Chosen插件-通过Ajax动态填充列表时显示加载图标
- 有没有一种方法可以用jQuery捕获JavaScriptPageMethods调用?(显示加载屏幕)
- jquery图片库显示加载程序gif