2013-08-19 72 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

是。这个伎俩。 –

相关问题