【发布时间】:2019-11-11 14:59:05
【问题描述】:
我正在尝试以角度获取 url 参数 我试过了
ngOnInit() {
this.route.paramMap.subscribe(params => {
console.log("test1",params)
})
//and
console.log("test2", this.route.snapshot.params)
}
ngAfterViewInit(){
}
它得到的响应: enter image description here
【问题讨论】:
-
嗨,看看 [this] (stackoverflow.com/questions/45997369/…)。您还可以提供如何传递参数吗?
-
第二条日志应该是
this.route.snapshot.paramMap而不是.params