2
我正在製作一個Angular應用程序,我很樂意告訴用戶它通過API下載信息需要多長時間。如何在角度顯示加載狀態
基本上我現在這樣做的:
app.controller('GlossaryCtrl', function ($scope, $http) {
$http({
method: 'GET',
url: 'http://example.com/api/v1/glossary',
})
.success(function(data) {
$scope.glossary = data;
})
.error(function(data) {
$scope.glossary = [
{"title": "Error:",
"description": "Please ensure you are connected to the internet or try again in a few minutes."}
];
});
});
現在,而詞彙表下載,是對我有辦法讓長度,它已下載?這樣我可以創建一個狀態欄。
最糟糕的部分是我已經準備好Bootstrap並且正在等待... – BenMorganIO
所以你可以在每個回調中使用一個標誌'$ scope.loaded'並且設置'ng-if =「!loaded」'進度酒吧。 ng-if根據表達式添加或刪除dom元素,而不是隱藏或顯示。 –