Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nb-route-tabset with parameters in URL #188

Closed
2 tasks done
aqsdc1 opened this issue Feb 5, 2018 · 4 comments · Fixed by #1146
Closed
2 tasks done

nb-route-tabset with parameters in URL #188

aqsdc1 opened this issue Feb 5, 2018 · 4 comments · Fixed by #1146

Comments

@aqsdc1
Copy link

aqsdc1 commented Feb 5, 2018

Issue type

I'm submitting a ... (check one with "x")

  • bug report
  • feature request

Issue description

Current behavior:

When using nb-route-tabset, the parameters are never sent correctly because the URL we provide is considered as a simple string. Which means that when we arrive at the targeted component, we cannot fetch data by reading the route parameters.

Expected behavior:

Being able to use parameters in the URL. Probably asking for an array in the route property and navigate to it in the NbRouteTabsetComponent should be enough ?

Steps to reproduce:

Related code:

Have a Groups module with these routes :

const routes: Routes = [
  {
    path: 'groups',
    children: [
      {
        path: '',
        component: GroupListComponent,
      },
      {
        path: ':id',
        component: GroupComponent,
        children: [
          {
            path: '',
            redirectTo: 'detail',
            pathMatch: 'full',
          },
          {
            path: 'detail',
            component: GroupDetailComponent,
          },
          {
            path: 'edit',
            component: GroupEditComponent
          }
        ],
      },
    ],
  }
];

In the GroupComponent ( I tried different way to define the route):

  ngOnInit() {
    this.route.params.subscribe(
      params => {
        this.tabs = [
          {
            title: 'Detail',
            route: ['groups' + params['id'] + '/detail'],
          },
          {
            title: 'Edit',
            route: '/groups/' + params['id'] + '/edit'
          },
        ];
      }
    );
  }

with this template : <nb-route-tabset [tabs]="tabs"></nb-route-tabset>

In the GroupDetailComponent:

ngOnInit() {
    this.route.params.switchMap(
      params => this.groupService.getGroup(params['id'])
    ).subscribe(group => this.group = group);
  }

Other information:

npm, node, OS, Browser

<!--
Node, npm: `node --version` and `npm --version`
OS: Windows (7/8/10). Linux (incl. distribution). macOS (El Capitan? Sierra?)
Browser: Chrome/Safari/Firefox/etc?
-->

node: v8.9.4
npm: 5.6.0
OS: Ubuntu 1604
Browser: firefox

Angular, Nebular

<!--
Check your `package-lock.json` or locate a `package.json` in the `node_modules` folder.
-->
@developcodeza-chris
Copy link

Hi, any update on this?

@suppadeliux
Copy link

Still nothing :(,

@yggg
Copy link
Contributor

yggg commented Jan 11, 2019

Hi guys! Fix planned on 3.2.0 release. Then you will be able to set route in any way supported by routerLink.

As a workaround, for now, you can provide dynamic values only via single strings. Like this:

this.route.params.subscribe(params => {
  this.tabs = [
    {
      title: 'Detail',
      route: `/groups/${params.id}/detail`,
    },
  ];
});

@Cvele85
Copy link

Cvele85 commented May 21, 2021

Hello, I've got a problem that I would like to add the route NavigationExtras and I can not find the right way. Im asking for help!

Examples I tried:

  this.tabs = [
    {
      title: this.translate.instant("pages.general.tabs.details"),
      responsive: true,
      route: [[`/reviews/events/types/${params.id}`], { queryParams: { returnUrl: this.returnUrl } }],
      tag: { queryParams: { returnUrl: this.returnUrl } },
      queryParams: { returnUrl: this.returnUrl },
      icon: 'list-outline',
    },

  this.tabs = [
    {
      title: this.translate.instant("pages.general.tabs.details"),
      responsive: true,
      route: [`/reviews/events/types/${params.id}?returnUrl=${this.returnUrl }`],
      tag: { queryParams: { returnUrl: this.returnUrl } },
      queryParams: { returnUrl: this.returnUrl },
      icon: 'list-outline',
    },

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants