我正在使用angularjs ui路由器,我需要默认加载子状态(即' dashboardParent.dashboard')。
$stateProvider.state('dashboardParent', {
abstract: true,
url: '/dashboard',
templateUrl: 'app/views/dashboard/dashboard-parent.html',
controller: 'DashboardParentController'
}).state('dashboardParent.dashboard', {
url: '/',
templateUrl: 'app/views/dashboard/dashboard.html',
controller: 'DashboardController'
})
一般来说,我们所做的是home
状态与网址(" /")从那里我们导航到其他状态,让我们说'dashboardParent.dashboard'
。但在这里,我没有任何home
州。当我启动应用程序时,我希望加载dashboardParent.dashboard
状态。如何实现它。
如果我添加另一个状态home
并提供导航到状态'dashboardParent.dashboard'
的链接,则表示正常加载。但我的要求是我没有任何家庭状态,而是我需要默认加载'dashboardParent.dashboard'
。如何实现呢?
答案 0 :(得分:0)
以下代码可以帮助您:
// if the path doesn't match any of the urls you configured
// otherwise will take care of routing the user to the specified url
$urlRouterProvider.otherwise('/');
注意:不要忘记注入$urlRouterProvider
服务。