1

I am using queryParams to include search parameters in my url. Then I have the following:

app.routing.module.ts

{path: 'buscar', component: BuscarComponent}

component.ts

 goSearch() {
    this.router.navigate(['/buscar'], { queryParams: { query: 'larapa' }} );
 }

component.html

<button (click)="goSearch()">myLink</button>

Then the result I get http://localhost:4200/buscar?query=larapa but instantly ?query=larapa disappears and as a final result I get http://localhost:4200/buscar

Is this normal behavior? Do I have something wrong set up? How can I do this to solve this?

Paco Zevallos
  • 2,165
  • 7
  • 30
  • 68

1 Answers1

0

If you want remain your params, how about use app-routing paramerters?

In App.routing.module.ts

{path: 'buscar:query', component: BuscarComponent}

then you can access url like this http://localhost:yourport/buscar/larapa

HEON
  • 11
  • 1
  • I need my final path to be with this format http: // localhost: 4200/search? query=larapa since I am using algolia as a search provider – Paco Zevallos Oct 24 '19 at 01:37