Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

181
Views
Pasar múltiples parámetros de ruta en Angular2

¿Es posible pasar múltiples parámetros de ruta, por ejemplo, como a continuación, necesita pasar id1 e id2 al component B ?

 @RouteConfig([ {path: '/component/:id :id2',name: 'MyCompB', component:MyCompB } ]) export class MyCompA { onClick(){ this._router.navigate( ['MyCompB', {id: "someId", id2: "another ID"}]); } }
over 4 years ago · Santiago Trujillo
3 answers
Answer question

0

OK me di cuenta de un error .. tiene que ser /:id/:id2

De todos modos, no encontré esto en ningún tutorial u otra pregunta de StackOverflow.

 @RouteConfig([{path: '/component/:id/:id2',name: 'MyCompB', component:MyCompB}]) export class MyCompA { onClick(){ this._router.navigate( ['MyCompB', {id: "someId", id2: "another ID"}]); } }
over 4 years ago · Santiago Trujillo Report

0

Como se detalla en esta respuesta , las respuestas de mayur y user3869623 ahora se relacionan con un enrutador obsoleto. Ahora puede pasar múltiples parámetros de la siguiente manera:

Para llamar al enrutador:

 this.router.navigate(['/myUrlPath', "someId", "another ID"]);

En rutas.ts:

 { path: 'myUrlpath/:id1/:id2', component: componentToGoTo},
over 4 years ago · Santiago Trujillo Report

0

Dos métodos para pasar múltiples parámetros de ruta en Angular

Método 1

En app.module.ts

Establezca la ruta como componente2.

 imports: [ RouterModule.forRoot( [ {path: 'component2/:id1/:id2', component: MyComp2}]) ]

Llame al enrutador para navegar a MyComp2 con múltiples parámetros id1 e id2.

 export class MyComp1 { onClick(){ this._router.navigate( ['component2', "id1","id2"]); } }

Método-2

En app.module.ts

Establezca la ruta como componente2.

 imports: [ RouterModule.forRoot( [ {path: 'component2', component: MyComp2}]) ]

Llame al enrutador para navegar a MyComp2 con múltiples parámetros id1 e id2.

 export class MyComp1 { onClick(){ this._router.navigate( ['component2', {id1: "id1 Value", id2: "id2 Value"}]); } }
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!