Can you pass a specific route determined by an id ? (Angular Routes)

Asked

Viewed 169 times

1

Ex : I want to register(I’m working with Tadata)

My route today {path:entity/:identity/registration}

Where the identity is replaced dynamically when I click, for example: in the database register menu :

the route becomes = {path:entity/BANK/registry.

What I want to do add an id to each identity

if the identity is = bank then the bank corresponds to id 1 logo, id:1= bank.

I want the routes to stay that way:

{path:/direct/:id Componentregistration}

But I have to check id to know which register to open.

id:1= bank id:2=branch

if id is 1 the sera {path: direct/1)

if id is 2 the route sera {path:direct/2)

I need help 'cause I don’t know how.

  • I could not understand your doubt. Try to provide some code to be clearer

2 answers

2

I solved with Dictionary typescript and this.router.navigate[()];

1

Maybe this will help:

You can capture the parameters with the Activatedroute as you specify the name of the parameters and with this you can catch the /:Identity/.

idEntidade: number;

constructor(private route: ActivatedRoute){
    this.idEntidade = this.route.snapshot.params.idEntidade;
}

With the identity, in the HTML of Componentcadastre, you can demonstrate which component of registration to demonstrate with the ngIf :

<app-cadastro-banco *ngIf="idEntidade === 1"></app-cadastro-banco>
<app-cadastro-filial *ngIf="idEntidade === 2"></app-cadastro-filial>

Browser other questions tagged

You are not signed in. Login or sign up in order to post.