我用angularjs有一个简单的http get调用
$http({
method: 'GET',
url: 'Dashboard/GetDashboard'
}).then(function successCallback(response) {
$scope.dashboard = response.data;
}, function errorCallback(response) {
console.log(response);
});
有时在加载仪表板时性能很低,我想使用Font Awesome中的加载微调器。这是我在索引上的html代码。
<i ng-hide="?" class="fa fa-refresh icon-options"></i>
我知道我要用ng hide,但我不知道我要用什么表达法。
当http调用完成时,我想隐藏加载微调器。
有人能告诉我正确的方向吗?
亲切的问候
最佳答案
使用一些布尔变量,将其放在调用之前,并在成功时使其true
如下所示:
使用ng-hide
$scope.isSpinnerHidden = false;
$http({
method: 'GET',
url: 'Dashboard/GetDashboard'
}).then(function successCallback(response) {
$scope.dashboard = response.data;
$scope.isSpinnerHidden = true;
}, function errorCallback(response) {
console.log(response);
});
<i ng-hide="isSpinnerHidden" class="fa fa-refresh icon-options"></i>
或者
如下所示使用
$scope.isSpinnerHidden = true;
$http({
method: 'GET',
url: 'Dashboard/GetDashboard'
}).then(function successCallback(response) {
$scope.dashboard = response.data;
$scope.isSpinnerHidden = false;
}, function errorCallback(response) {
console.log(response);
});
<i ng-show="isSpinnerHidden" class="fa fa-refresh icon-options"></i>
希望有帮助!啊!