Angular UI-Router:嵌套状态/视图显示路由但不显示模板

Kur*_*ler 1 angularjs angular-ui angular-ui-router

我目前正在使用Angular UI-Router 0.0.2我的角应用中的路线/状态.在我的应用程序中,我有一个仪表板和一个帐户页面 - 仪表板显示应用程序数据; 帐户页面显示用户信息.

当我有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'
)
Run Code Online (Sandbox Code Playgroud)

但是,每当我将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'
)
Run Code Online (Sandbox Code Playgroud)

我的dashboard/index.html档案:

%section.row-fluid
  .span12
    / directive
    %loginform
Run Code Online (Sandbox Code Playgroud)

我的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
Run Code Online (Sandbox Code Playgroud)

Tim*_*erg 5

添加ui-view到您的信息中心/ index.html模板.