I'm trying to get a parameter serverId
from the URL using the following setup:
constructor(private peopleService: PeopleService, private route: ActivatedRoute) {
this.route.paramMap.subscribe(params => {
console.log(params); //params is empty here
//...
Here's my setup in app.module.ts:
@NgModule({
declarations: [AppComponent],
imports: [BrowserModule, HttpClientModule, RouterModule.forRoot([])],
providers: [],
bootstrap: [AppComponent],
})
I've also tried using queryParams
instead of paramMap
, any method I've seen results in an empty parameter list so I'm assuming there's something wrong with my setup.
Is there something else I need to do to set this up? I'm providing the parameter correctly in the url as url?serverId=123
.