请, 我在我的项目中使用ui-router。当用户在状态之间导航时,$stateChangeStart
事件正常工作。 但是,如果我刷新浏览器,它不起作用。
这是我的源代码:
(function(){
'use strict';
angular.module('app.overlay')
.directive('ibLoading', ['$rootScope' , '$timeout', loading]);
function loading($rootScope , $timeout){
console.log("In dirrective");
var directive = {
restrict:'EAC',
link:link
};
function link(scope, element) {
$rootScope.$on('$stateChangeStart', function() {
$timeout(function(){
element.addClass('show');
} , 50);
});
$rootScope.$on('$stateChangeSuccess', function() {
$timeout(function(){
element.removeClass('show');
} , 700);
});
}
return directive;
}
})();
我的布局文件
<div ng-controller="ShellController as vm">
<header class="clearfix">
<ht-top-nav navline="vm.navline"></ht-top-nav>
</header>
<section id="content" class="content">
<!--<div ng-include="'app/layout/sidebar.html'"></div>-->
<div ui-view></div>
<div class="ib-loading">Loading ...</div>
</section>
</div>
你能否提供一些代码的例子吗? –
这将取决于它在哪里使用。没有任何代码,没有人可以帮助你。加载页面时,请提供 – charlietfl
你期待指令寄存器的初始变化相关的代码?它不会。仍然不清楚问题是什么或预期的行为 – charlietfl