我尝试制作正确的 View 加载应用程序。
HTML:
<body>
<loading outerWidth='1000' outerHeight='1000' display='isReady'></loading>
<div class='wrapper' ng-show='isReady'>
</div>
</dody>
JS:
app.run(['$rootScope', '$state', '$stateParams', '$location', '$http', 'userData', function($rootScope, $state, $stateParams, $location, $http, userData) {
$rootScope.isReady = false;
$http.post('services/enter.php', {
}).then(function(response) {
$rootScope.isReady = true;
});
}]);
基本思想:当应用程序加载时显示一些图像/加载 gif“请稍候”。下一篇文章请求获取数据并在请求后显示 html。但我在从 app.rum 函数操作 html 时遇到问题 - 我尝试使用 $rootScope。需要建议我如何做得更好。
最佳答案
让这个answer你的问题,$httpProvider.interceptors,在发送ajax请求$http并广播它之前和之后处理。
关于javascript - 如何通过 ng-if/ng-show/ng-hide 从 app.run 函数正确隐藏/显示 html?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38041673/