Open Closed

How to pass query parameter to the route at the end of route? #708


User avatar
0
lalitChougule created

Check the docs before asking a question: https://docs.abp.io/en/commercial/latest/ Check the samples, to see the basic tasks: https://docs.abp.io/en/commercial/latest/samples/index The exact solution to your question may have been answered before, please use the search on the homepage.

  • ABP Framework version: v3.0.4

  • UI type: Angular / MVC: Angular

  • DB provider: EF Core / MongoDB

  • Tiered (MVC) or Identity Server Seperated (Angular): yes / no : no

  • Exception message and stack trace: Working: http://localhost:4200/account;accountType=supplier/login Exptected Result: http://localhost:4200/account/login?accountType=supplier

  • Steps to reproduce the issue: We customize the AccountComponent

app.module.ts

@NgModule({
  declarations: [AppComponent, AccountComponent, .....],
   imports: [
		 AccountConfigModule.forRoot(),
         IdentityConfigModule.forRoot(),
		....
		.....
		],
	entryComponents: [AccountComponent]	

app-routing.module.ts

const routes: Routes = [
  {
    path: '',
    loadChildren: () => import('./home/home.module').then((m) => m.HomeModule)
  }
   {
    path: 'account',
    loadChildren: () => import('@volo/abp.ng.account')
    .then((m) => m.AccountModule.forLazy({ redirectUrl: '/' })),
  },
   {
    path: 'dashboard',
    loadChildren: () => import('./dashboard/dashboard.module').then((m) => m.DashboardModule),
	}]

Home.component.ts

	 if (this.hasLoggedIn){
		this.router.navigate(['dashboard'])
	 }else {
		 this.router.navigate(['account', { accountType: 'supplier' }]);
	 }

How to acheive this, Kindly give any suggestions

Thanks


1 Answer(s)
  • User Avatar
    0
    Mehmet created

    Hi @lalitChougule

    Please change the navigating code as the following:

     this.router.navigate(['account'], {queryParams: accountType: 'supplier' });
    
Made with ❤️ on ABP v8.2.0-preview Updated on March 25, 2024, 15:11