我注意到在初始加载主页时,我的viewContentLoaded事件会触发两次,为什么会这样?
app.run(function
($rootScope,$log) {
'use strict';
$rootScope.$state = $state;
$log.warn("gets here");
$rootScope.$on('$viewContentLoaded',function(){
$log.warn("gets here2");
});
});
页面加载时的输出
"gets here"
"gets here2"
"gets here2"
以下是我的路由设置
$urlRouterProvider.when('', '/');
// For any unmatched url, send to 404
$urlRouterProvider.otherwise('/404');
$stateProvider
.state('home', {
url: '/',
templateUrl: 'views/search.html',
controller: 'SearchCtrl'
})
我的Index.html
<div id="canvas">
<ng-include src="'views/partials/header.html'"></ng-include>
<!-- container -->
<div ui-view ></div>
<!-- /container -->
<ng-include src="'views/partials/footer.html'"></ng-include>
</div>