請, 我在我的項目中使用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