我真的需要你的幫助,我是離子項目的新手。目前正在從事一個項目。這個應用程序使用$ http從wordpress中獲取博客文章。如何添加進度條來告訴用戶頁面正在加載,而不是空白屏幕?由於如何在離子應用程序中添加進度條
0
A
回答
0
您可以使用$ionicLoading
可以用於指示活動,同時阻止用戶交互的疊加。
加載在控制器內被觸發。首先我們需要在控制器中注入$ ionicLoading作爲依賴。之後,我們需要調用$ ionicLoading.show()方法並加載。爲了禁用它,有$ ionicLoading.hide()方法。
例子: -
.controller('myCtrl', function($scope, $ionicLoading) {
$scope.showLoading = function() {
$ionicLoading.show({
template: 'Loading...'
});
};
$scope.hideLoading = function(){
$ionicLoading.hide();
};
});
0
您可以使用$httpProvider.interceptors
跟蹤http
電話。
您可以找到工廠寫在你的項目中添加以下代碼 here
或者
你可以做到這一點,以顯示離子裝載機。
添加以下代碼angular.module('app',[]).run(...)
$rootScope.$on('loading:show', function() {
$ionicLoading.show({ template: '<ion-spinner class="spinner-assertive"></ion-spinner>' })
})
$rootScope.$on('loading:hide', function() {
$ionicLoading.hide()
})
添加以下代碼angular.module('app',[]).config(...)
$httpProvider.interceptors.push(function ($rootScope) {
return {
request: function (config) {
$rootScope.$broadcast('loading:show')
return config
},
response: function (response) {
$rootScope.$broadcast('loading:hide')
return response
}
}
})
0
使用$ionicLoading
指令來顯示和隱藏的好手。這是一個例子。在之前撥打show()
,然後在.success()
之後隱藏。
controller('myCtrl', function($scope, $ionicLoading) {
$ionicLoading.show({
template: '<ion-spinner icon="android"></ion-spinner>'
});
$http({
method: 'POST',
url: 'http://example.com',
})
.success(function(){
$ionicLoading.hide();
});
});
相關問題
- 1. 如何將Ajax進度條添加到React.js應用程序?
- 2. 如何在離子應用程序中添加Admob?
- 3. 如何在plupload中添加進度條?
- 4. 如何添加進度條
- 5. 添加進度條上傳程序
- 6. 如何在離子混合應用程序中顯示通知下載進度?
- 7. 在IE中慢速加載AngularJS應用程序 - 添加進度條
- 8. 如何在iPhone應用程序中使用進度條
- 9. 如何在WinForm應用程序中使用進度條C#
- 10. 向Wix引導程序應用程序的進度條添加附加信息
- 11. 如何將進度條添加到我在C#中的SharpZipLib實用程序中
- 12. 如何在JavaScript中爲Phonegap應用程序編寫進度條
- 13. 如何在Windows應用程序中顯示進度條?
- 14. 如何在JSF應用程序中繪製進度條
- 15. 如何在Adobe Air應用程序中顯示進度條?
- 16. 如何添加TestFairy離子2應用
- 17. 如何在離子應用程序中添加實時位置跟蹤
- 18. iOS離線Web應用程序 - 進度條?
- 19. 在我的應用程序中添加進度條以跟蹤任務移動
- 20. 如何在離子3中設計圓形進度條?
- 21. 添加進度條
- 22. 添加進度條
- 23. 在應用程序初始化後添加角度離子視圖和路線
- 24. 如何在應用程序底部顯示webview進度條?
- 25. 如何爲windows mobile應用程序的webview項目添加進度條或進度環
- 26. 如何將mapbox.js添加到我的離子/科爾多瓦應用程序中?
- 27. 如何添加「更多」按鈕到標籤欄在離子應用程序?
- 28. 如何在角度應用程序中向父級添加類?
- 29. 任務/進度條JavaFX應用程序
- 30. 如何添加進度條的延遲