Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular2 - Passing params to named outlet

I need to pass params to a named outlet, from a default outlet. After passing, all I get is 'undefined'. Here is my code.

[routerLink]="['', { outlets: { secondOutlet: 'messages' }, name: this.userName, lastName: this.userLastName}]"

I receive params with this.

    this.route$ = this.route.params.subscribe((params: Params) => {
     this.name= params['name'];
     this.lastName= params['lastName'];
   });

I get no error, but in console, all I get is undefined. I can send params to a route if it is on the same outlet, but I cant figure out how to do it by sending params from one outlet to another.

like image 812
BrS Avatar asked Jan 29 '23 16:01

BrS


1 Answers

  [routerLink]="['', { outlets: { secondOutlet: ['messages', this.userName ] } }]"

and in route specification

Routes = [
{
    path: 'messages/:username',
    component: AccountsEditComponent,
    outlet: 'secondOutlet'
  }
]
like image 151
akshaya rathinavel Avatar answered Feb 07 '23 10:02

akshaya rathinavel