【发布时间】:2021-08-23 05:12:07
【问题描述】:
我有一个组件通过一些条件参数路由到另一个组件
这是定义路由的代码:
redirect(topicname : string){
alert(topicname)
this.router.navigate(['/chapters'], { queryParams: { topic: topicname } });
}
在我定义的 Chapters.component.ts 文件中:
export class ChapterstemplComponent implements OnInit {
topic : string;
constructor( private route : ActivatedRoute) {
this.topic= this.route.snapshot.params.topic;
alert( this.route.snapshot)
}
但是 this.topic 没有收到任何值。我想在我的 chapters.component 的 HTML 文件中使用它。 注意:警报消息确认“topicname”在第一个 sn-p 中发送良好 但是在第二个sn -p中,路由没有收到任何参数 这是相同的图像:
【问题讨论】:
标签: angular query-parameters angular-activatedroute