Angular <router-outlet name=“popup”> change URL path structure?

微笑、不失礼 提交于 2019-11-28 02:01:42

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 
    }
  ]

That is how Angular handles multiple outlets. I do not think you will be finding a "clean" solution for this. Just dont use name router outlets, then. Have one single router outlet without a name.

[routerLink]="['popup']">

{
  path: 'mypopup',
  component: MyComponent
},

<router-outlet name="popup"></router-outlet>

Unfortunately, it seems like you do have multiple routers in your project, so this is probably not a solution. I will backup the other commenters when they said there currently is not an easy clean way. I also want a different routing solution, so hopefully we can complain enough that they find a new way.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!