[英]Show MODAL in onsen ui while data is fetching in angularjs
我正在嘗試從服務器獲取數據。 自從獲取以來,我想顯示一個模態,直到未完全加載。
這是我正在使用的。
<ons-page ng-controller="directoryControl">
<ons-modal var="modal">
<ons-icon icon="ion-load-c" spin="true"></ons-icon>
<br><br>
Please wait.<br>Closing in 2 seconds.
</ons-modal>
<ons-list>
<ons-list-item modifier="chevron" class="list-item-container" ng-repeat="PostCategory in PostCategories">
<ons-row>
<ons-col>
<div class="name">
{{PostCategory.title}}
</div>
</ons-col>
</ons-row>
</ons-list-item>
</ons-list>
</ons-page>
我的模態在angularjs中是這樣的。
var module = angular.module('app', ['onsen']);
module.controller('directoryControl', function($scope, $http) {
ons.ready(function() {
//console.log($scope.username + ", " + $scope.password);
modal.show();
var responsePromise = $http.get("http://www.mywebsitepadth.com/api/get_category_index/");
responsePromise.success(function(data, status, headers, config) {
modal.hide();
});
responsePromise.error(function(data, status, headers, config) {
alert("ajax didnt work");
});
});
});
我可以知道為什么我在執行modal.show();
時不顯示模式modal.show();
?
謝謝!
這樣使您的模特身材直子。
<body>
<ons-modal var="modal">
<ons-icon icon="ion-load-c" spin="true"></ons-icon>
<br><br>
Please wait.<br>Closing in 2 seconds.
</ons-modal>
這樣,您將可以在任何控制器中的任何位置訪問模式。 現在您的控制器應該是這樣的。
module.controller('directoryControl', function($scope, $http) {
//console.log($scope.username + ", " + $scope.password);
modal.show();
var responsePromise = $http.get("http://www.mywebsitepadth.com/api/get_category_index/");
responsePromise.success(function(data, status, headers, config) {
modal.hide();
});
responsePromise.error(function(data, status, headers, config) {
alert("ajax didnt work");
});
});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.