javascript – 如何在角度2的ui-router中使用`otherwise`?

在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] })

相关文章

ANGULAR.JS:NG-SELECTANDNG-OPTIONSPS:其实看英文文档比看中...
AngularJS中使用Chart.js制折线图与饼图实例  Chart.js 是...
IE浏览器兼容性后续前言 继续尝试解决IE浏览器兼容性问题,...
Angular实现下拉菜单多选写这篇文章时,引用文章地址如下:h...
在AngularJS应用中集成科大讯飞语音输入功能前言 根据项目...
Angular数据更新不及时问题探讨前言 在修复控制角标正确变...