Ah sorry, I get it, I have declared it in my ap.routing.module.ts file but
I am still getting the error?!
I am trying to pass data onto my service file
On Monday, February 11, 2019 at 4:38:42 PM UTC, John Biddulph wrote:
>
> hmm,
>
> I have imported Router import { Router } from '@angular/router';
>
> and I have set it in the constructor: private router: Router
>
> not sure what you are suggesting to do with the following:
>
> const routes: Routes = [
> {
> path: '',
> component: DashboardComponent,
> },
> ];
>
>
>
>
>
> On Monday, February 11, 2019 at 4:18:33 PM UTC, Tito wrote:
>>
>> have you declared your routes? You are asking to go to this towns route
>> but there is no exit sign ;)
>>
>> const routes: Routes = [
>> {
>> path: '',
>> component: DashboardComponent,
>> },
>> ];
>>
>>
>> On Monday, February 11, 2019 at 7:26:59 AM UTC-8, John Biddulph wrote:
>>>
>>> I am following this tutorial:
>>> https://alligator.io/angular/query-parameters/
>>>
>>> here is my code:
>>> townClicked($event) {
>>> this.router.navigate(['/pubs'], { queryParams: { town: $event } });
>>> }
>>>
>>> and so I get the error
>>>
>>> Error: Uncaught (in promise): Error: Cannot match any routes. URL
>>> Segment: 'pubs'
>>>
>>>
>>> and when I am trying to get the town that is clicked, here is my code:
>>> // tslint:disable-next-line:use-life-cycle-interface
>>> ngOnInit() {
>>> this.route.queryParams
>>> .filter(params => params.town)
>>> .subscribe(params => {
>>> console.log(params); // {order: "popular"}
>>>
>>> this.selectedTown = params.town;
>>> console.log(this.selectedTown); // popular
>>> });
>>> }
>>>
>>
--
You received this message because you are subscribed to the Google Groups
"Angular and AngularJS discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.