我有一个角度应用,在该应用中加载了多个视图。我想知道每个视图如何在事件上广播以说明其视图已被加载。
我有一条基本路线: -
$stateProvider.state('root-profile', {
abstract: true,
views: {
'@': {
templateUrl: 'app/shared/base-profile/base-profile-view.html',
controller: 'baseProfileController'
},
'header@root-profile': {
templateUrl: 'app/shared/header-profile/header-profile-view.html',
controller: 'headerProfileController'
},
'leftSideBar@root-profile': {
templateUrl: 'app/shared/sidebar/left/left-side-bar-view.html',
controller: 'leftSideBarController'
},
'rightSideBar@root-profile': {
templateUrl: 'app/shared/sidebar/right/right-side-bar-view.html',
controller: 'rightSideBarController'
},
'footer@root-profile': {
templateUrl: 'app/shared/footer-profile/footer-profile-view.html',
controller: 'footerProfileController'
}
} //END views
}); //END state
我的路由如上所示。是否可以知道何时加载了以下每个视图。我想到了广播和事件视图中的每个控制器,但问题是如何知道特定视图是否已加载。通过加载我的意思是它的视图已被加载。
答案 0 :(得分:0)
您可以使用以下内容:
$scope.$on('$viewContentLoaded', function(){
//Here your view content is fully loaded !!
});