javascript - 如何通过 ng-if/ng-show/ng-hide 从 app.run 函数正确隐藏/显示 html?

标签 javascript jquery html angularjs

我尝试制作正确的 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/

相关文章:

html - "Mobile" Bootstrap 导航栏不工作

iphone - 如何使用 HTML5 开发 iPhone 应用程序?

css - 页面内容和页脚之间的巨大差距

javascript - 为什么这个 promise 不起作用?

javascript - jquery hide()/show() 动画连续重复

javascript - 用按钮显示隐藏元素

javascript - Meterializecss- Wordpress 下拉导航

javascript - flow.js 点击上传文件

javascript - 数据排序方法在 JavaScript 中不起作用

javascript - 任何人都可以给我关于如何让它在 ie 中工作的建议吗?