Extract id from url using Angular2

后端 未结 6 936
有刺的猬
有刺的猬 2021-02-03 17:57

Hi I am trying to extract the id part of the url using Angular2.

http://localhost:3000/item/187809

I have been playing around with ActiveRoute

6条回答
  •  一向
    一向 (楼主)
    2021-02-03 18:42

    this.routeSub = this.route.params.subscribe(params => {
       console.log(params);
       console.log(+params['id']);
    }); 
    

提交回复
热议问题