我有問題加載我的子狀態抽象真正的父狀態。角度ui路由器如何等待子狀態被加載
這是我的父狀態
.state('main', {
url: '/main',
templateUrl: 'templates/main.html',
abstract: true
})
這是孩子指出
.state('main.panels', {
views: {
'ticketsPanel': {
templateUrl: 'templates/ticketsPanel.html'
},
'productsPanel': {
templateUrl: 'templates/productsPanel.html'
},
'categoriesPanel': {
templateUrl: 'templates/categoriesPanel.html'
}
}
})
我有一個登錄頁面後,我登錄我要加載所有3層孩子的意見。
這是處理登錄的代碼。
.controller('loginController', function($scope, Authentication, $log, $state){
$scope.formData = {};
$scope.processForm = function(){
Authentication.login($scope.formData);
var promise = Authentication.getEmployee();
promise.then(function(respond){
localStorage.setItem('employee', JSON.stringify(respond));
$state.go('main.panels');
})
}
})
的$ state.go(「main.panels」)激活主狀態父母的孩子的狀態,但我遇到的問題是,DOM是顯示已被加載的元素,但我只能在我看來部分看到他們。這就像他們沒有滿載。
我的問題是我如何等待main.panels中的所有視圖在我轉換到該視圖之前完全加載。
我讀到的UI路由器 '解析'。它實際上解決了與國家相關的問題。所以,不是每個視圖都有相同的解決方案,你實際上只能在狀態中提供'解決'一次。讓我知道如果這聽起來令人困惑:) –