How to use ActivatedRoute in Angular 5?

前端 未结 5 511
-上瘾入骨i
-上瘾入骨i 2020-12-16 19:26

I am trying to do exactly the same thing as in this post: Angular 4 get queryString

I am using Angular 5.2.5.

ActivatedRoute seems to be the thing to use to

5条回答
  •  青春惊慌失措
    2020-12-16 19:45

    I made the two changes Arun suggested. Then, to fix the "No provider for ActivatedRoute" error, I made the changes shown below.

    1) I added this line to the app.module.ts:

    import { RouterModule } from '@angular/router';
    

    2) I added this line to the imports array of the @NgModule in app.module.ts:

    RouterModule.forRoot([])
    

    This article gave me the fix: Angular error: no provider for ActivatedRoute

    Now it compiles. Hooray!

提交回复
热议问题