最佳答案
路线
const appRoutes: Routes = [
{ path: '', redirectTo: '/companies/unionbank', pathMatch: 'full'},
{ path: 'companies/:bank', component: BanksComponent },
{ path: '**', redirectTo: '/companies/unionbank' }
]
组件
const NAVBAR = [
{
name: 'Banks',
submenu: [
{ routelink: '/companies/unionbank', name: 'Union Bank' },
{ routelink: '/companies/metrobank', name: 'Metro Bank' },
{ routelink: '/companies/bdo', name: 'BDO' },
{ routelink: '/companies/chinabank', name: 'China Bank' },
]
},
...
]
链接示例: http://localhost:8099/#/companies/bdo
我想得到 String
bdo在上面的例子链接。
我知道我可以通过使用 window.location.href 获得链接,并将其拆分为数组。我可以得到最后一个参数,但是我想知道,有没有合适的方法,用角度的方式做这个。
Any help would be appreciated. Thanks