Accessing Route data in root component, route data is empty

后端 未结 1 1468
[愿得一人]
[愿得一人] 2021-01-18 05:38

My problem is that I have a lang.component loaded with . What I need is to access ActivatedRoute params in the root component

相关标签:
1条回答
  • 2021-01-18 06:10

    Instead of using ActivatedRoute use Router.

    this.router.events.subscribe((event) => {
        if(event instanceof NavigationEnd) {
            var snapshot = this.router.routerState.firstChild(this.route).snapshot;
    
            var params = snapshot.params;
        }
    })
    
    0 讨论(0)
提交回复
热议问题