如何定义用于从具有数据的URL加载上一个组件的路由?
以下是我
const routes: Routes = [
{
path: 'nav',
component:NavComponent,
children:[
{
path: 'basic-profile',
component: BasicProfileComponent
},
{
path: 'search',
component: SearchComponent
},
{
path:'business-profile',
component: BusinessProfileComponent
},
{
path:'search/business-card-full-view/:businessAccountId',
component: BusinessCardFullViewComponent,
},
{
path:'messaging',
component: MessagingComponent,
}
]
},
];
在URL的
路线http:// localhost:4200/nav/search/business-card-full-view/10
{
path:'search/business-card-full-view/:businessAccountId',
component: BusinessCardFullViewComponent,
},
我想去
http:// localhost:4200/nav/messaging
{
path:'messaging',
component: MessagingComponent,
}
通过单击一个按钮来发送此URL。
<button mat-button routerLink="messaging">Message</button>
按钮在BusinessCardfullviewComponent中。
我该怎么做?
我也尝试 redirectto ,
{
path:'search/business-card-full-view/:businessAccountId',
component: BusinessCardFullViewComponent,
children:[
{
path:'messaging',
redirectTo:'messaging',
}
]
},
但不起作用!
我使用路由器进行工作,如下所示
messaging()
{
this.router.navigate(['nav/messaging']);
}
。
Following are my routes
const routes: Routes = [
{
path: 'nav',
component:NavComponent,
children:[
{
path: 'basic-profile',
component: BasicProfileComponent
},
{
path: 'search',
component: SearchComponent
},
{
path:'business-profile',
component: BusinessProfileComponent
},
{
path:'search/business-card-full-view/:businessAccountId',
component: BusinessCardFullViewComponent,
},
{
path:'messaging',
component: MessagingComponent,
}
]
},
];
I am at URL
http://localhost:4200/nav/search/business-card-full-view/10
{
path:'search/business-card-full-view/:businessAccountId',
component: BusinessCardFullViewComponent,
},
I want to go the
http://localhost:4200/nav/messaging
{
path:'messaging',
component: MessagingComponent,
}
this URL by clicking one button.
<button mat-button routerLink="messaging">Message</button>
button is in BusinessCardFullViewComponent.
How can I do this?
I try redirectTo also
{
path:'search/business-card-full-view/:businessAccountId',
component: BusinessCardFullViewComponent,
children:[
{
path:'messaging',
redirectTo:'messaging',
}
]
},
But not working!
I do my work using Router as follows
messaging()
{
this.router.navigate(['nav/messaging']);
}
It works..!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论