【发布时间】:2019-08-17 16:19:22
【问题描述】:
当用户单击菜单选项时,我想路由到特定页面。我已经创建了一个带有相应事件的方法,但我不知道如何路由到在菜单上单击的特定页面。
menuEvent(event: any): any {
if (event.item.label == 'First Page') {
// redirect to 'first-view'
}
}
路由已在app-routing 模块中定义:
const routes: Routes = [
{
path: '',
pathMatch: 'full',
redirectTo: 'first-view'
},
{
path: 'first-view',
component: FirstViewComponent
},
{
path: 'second-view',
component: SecondViewComponent
},
}
这似乎很简单,但我是 Angular 新手,所以还不能完全理解它。
【问题讨论】:
标签: angular typescript