1
我目前在我的角度应用中使用Angular UI-Router 0.0.2
作为路由/状态。在我的应用程序中,我有一个仪表板和帐户页 - 仪表板显示应用程序数据;账户页面显示用户信息。Angular UI-Router:嵌套状态/视图显示路由但不是模板
当我有dashboard
和account
状态作为两个独立状态时,路线将改变并且帐户页面将显示。
此代码:
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
是。这个伎俩。 –