2013-08-19 69 views
1

我目前在我的角度應用中使用Angular UI-Router 0.0.2作爲路由/狀態。在我的應用程序中,我有一個儀表板帳戶頁 - 儀表板顯示應用程序數據;賬戶頁面顯示用戶信息。Angular UI-Router:嵌套狀態/視圖顯示路由但不是模板

當我有dashboardaccount狀態作爲兩個獨立狀態時,路線將改變並且帳戶頁面將顯示。

此代碼:

routes = app.config ($stateProvider, $urlRouterProvider) -> 

$urlRouterProvider.otherwise '/' 

$stateProvider.state('dashboard', 
    url: '/' 
    templateUrl: "app/views/dashboard/index.html" 
    controller: 'DashboardIndexCtrl' 
).state('account' 
    url: '/account' 
    templateUrl: "app/views/account/index.html" 
    controller: 'AccountIndexCtrl' 
) 

但是,每當我做account狀態爲嵌套的dashboard說,只有一個空白屏幕。

此代碼不起作用:

routes = app.config ($stateProvider, $urlRouterProvider) -> 

$urlRouterProvider.otherwise '/' 

$stateProvider.state('dashboard', 
    url: '/' 
    templateUrl: "app/views/dashboard/index.html" 
    controller: 'DashboardIndexCtrl' 
).state('dashboard.account' 
    url: 'account' 
    templateUrl: "app/views/account/index.html" 
    controller: 'AccountIndexCtrl' 
) 

dashboard/index.html文件:

%section.row-fluid 
    .span12 
    /directive 
    %loginform 

loginform指令的模板:

loginFormCtrl = app.controller 'LoginFormCtrl', ($scope, $rootScope, $location, $state, $log, User, Session) -> 

    $rootScope.logged_in = false 

    User.current().$promise.then (success) -> 
    $log.info success 
    $rootScope.current_user = success.user 
    $rootScope.logged_in = true if success.user.user_name != null 

回答

5

添加ui-view到您的儀表板/ index.html模板。

+0

是。這個伎倆。 –

相關問題