angularjs - rootScope 变量为 ng-if 延迟了两秒
问题描述
下面的代码是 app.js
var app = angular.module('inkwiry', [
'ngSanitize',
'ui.select',
'ui.bootstrap',
'ngCookies',
'oc.lazyLoad',
'ngAnimate',
'ui.bootstrap-slider',
'duScroll',
'ui.router',
'ngResource',
'jQueryScrollbar',
'angular-confirm',
'ngCkeditor',
'ngScrollbars',
'angularUtils.directives.dirPagination',
'ngDragDrop',
'fixed.table.header',
'stripe'
]);
app.run(function($rootScope, $state, $location, $window) {
$rootScope.$on("$stateChangeStart", function(event, toState, toParams, fromState, fromParams) {
$rootScope.loader = {
loading: true
};
console.log('app start');
});
$rootScope.$on("$locationChangeSuccess", function(event, toState, toParams, fromState) {
$rootScope.loader = {
loading: false
};
console.log('app end');
});
});
2) index.html
<div id="overlay" class="overlay" ng-if="loader.loading">
<div class="loading" id="loading">
<img src="external/img/ripple.svg">
<h1>Loading, Please wait...</h1>
</div>
</div>
我已经尝试了很多方法,但在本地它工作正常,但仍然存在同样的问题,但在服务器上它来晚了。变量的状态正在改变,但它会在 2 到 3 秒后应用于 div。我已经删除了 ngAnimate 也仍然是同样的问题。可以帮忙。
解决方案
推荐阅读
- python-3.x - Pyscreenshot ImageGrab.grab() 重新启动程序
- ios - 在 tableview 重新加载期间绘制一条线的问题
- mysql - 我需要 mysql 查询 wordpress 以获得有序列表
- javascript - 反应 | 如何检测页面刷新 (F5)
- python-2.7 - 熊猫使用自定义排序顺序创建直方图
- java - java.lang.NoClassDefFoundError: org/springframework/core/io/Resource 异常
- node.js - 如何将“apollo-fetch”graphql响应存储在变量中?
- python - 通过 API 将 csv 数据加载到 Big Query
- scala - 根据每个组的 spark/scala 时间窗口查找上次发生的时间
- javascript - 在 Codepen 项目中使用 fullpage.js 时遇到问题