在ui-router中,我们可以添加其他方式来处理无效/未注册状态.这是在AngularJS中
$urlRouterProvider.otherwise('/index');
这意味着,每个无效的URL最终都会转到’/ index’.我们如何在ui-router中为Angular 2做同样的事情?我已经在app.module.ts的导入中使用了UIRouterModule.forRoot()和UIRouterModule.forChild().
UIRouterModule.forRoot({ states: [loginState] }),
UIRouterModule.forChild({ states: [homeState] })
解决方法:
UIRouterModule.forRoot
docs显示了如何使用其他属性的示例:
UIRouterModule.forRoot({ states: [loginState], otherwise: '/index' }),
UIRouterModule.forChild({ states: [homeState] })