$ httpを使用してajaxリクエストを使用しています。サーバーでの操作に時間がかかるので、時間がかかります。リクエストを処理中にローダーを表示する必要がありますが、ローダーは表示されません。私のコードは正しいようですが。私は別の方法を試みたが、うまくいかなかった。角度jsのajaxリクエストでローダーが表示されない
Index.htmlと
<body ng-app="app">
<!-- loader, can be used on multiple pages-->
<div class="loading loader-quart" ng-show="isLoading"></div>
<!-- my logic -->
</body>
addCtrl.js
//method to get all the attributes and send to server using service
$scope.add = function() {
if ($scope.Option == 'newInstance')
$scope.singleObject.FK_Name = 'MetisEmptyTemplate';
$rootScope.isLoading = true;
var featuresList = websiteService.getUpdatedTree($scope.treeDataSource);
var formData = new Website("", $scope.singleObject.Name, $scope.singleObject.DisplayName, $scope.singleObject.Description, $scope.singleObject.State, "", $scope.singleObject.FK_Name, $scope.singleObject.Email, featuresList);
websiteService.addwebsite(formData);
$rootScope.isLoading = false;
}
websiteService.js
//service to add website
this.addwebsite = function (website) {
$http({
method: 'POST',
url: $rootScope.url + 'Add',
data: JSON.stringify(website),
contentType: 'application/json'
}).success(function (data) {
alert(data);
}).error(function (data, status, headers, config) {
//alert(data);
});
}
シン私はisLoadingを "true"に設定し、要求が完了したらisLoadingを "false"にします。コードのどこに問題がありますか?
あなたはあなたがする必要があるので、 '$ rootScope'の上に置きます:' NG-ショー= "$ root.isLoading" ' – devqon
しかし、また、動作しないこと。 rootscopeはアプリ内のすべてにアクセスできるので、 – Umar