我目前Angular UI-Router 0.0.2
在我的角度应用程序中使用路由/状态。在我的应用程序中,我有一个仪表板和一个帐户页面——仪表板显示应用程序数据;帐户页面显示用户信息。
当我将dashboard
andaccount
状态作为两个独立的状态时,路由会发生变化,并且会显示帐户页面。
此代码有效:
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