I'm using a popup (refering to the docs): https://angular.io/guide/router#displaying-multiple-routes-in-named-outlets
Everything is fine apart from the URL structure:
/domain/subPath/(popup:myopoup)
How can I change this default structure with parenthesis? I would like it to be as follows:
/domain/subPath/popup
In other words, I want to remove the brackets including the colon inside the URL.
Inside their documentation the popup also appears in that manner (with brackets)
Here is some code:
.ts
{
path: 'mypopup',
component: MyComponent,
outlet: 'popup'
},
.html
<a [routerLink]="[{ outlets: { popup: ['mypopup'] } }]">Contact</a>
<router-outlet name="popup"></router-outlet>
you can use URL serializer, to change url structure
import { UrlTree ,DefaultUrlSerializer, UrlSerializer } from '@angular/router';
export class cleanUrlSerializer extends DefaultUrlSerializer {
public parse(url: string): UrlTree {
function cleanUrl(url) {
return url.replace(/\(|\)/g,'') // for example to delete parenthesis
}
return super.parse(cleanUrl(url));
}
}
import this class and add it as provider in your module
providers: [
{
provide: UrlSerializer,
useClass: cleanUrlSerializer
}
]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With