如何从Angular 4 RouterModule解码#

问题描述 投票:0回答:1

我对Angular 4 #RouterModule有一点问题,我为root创建了一个ID

   RouterModule.forRoot([
        {path: ''                 , component: HomeComponent},
            {path: 'cautare/:id'  , component: RezultComponent},
            {path: 'profile'      , component: ProfileComponent},
            {path: 'contact'      , component: ContactComponent}
        ]),

在这个溃败ID我需要给这样的东西'3003KIV,BCM1504 #e'当我的表单触发搜索即时动态创建id

                // Pacs Class
                if (date[2].pacsClass) {
                    if (date[2].pacsClass === 'Economic') {
                        Link = Link + '#e';
                    }
                    if (date[2].pacsClass === 'Premium Economic') {
                        Link = Link + '#P';
                    }
                    if (date[2].pacsClass === 'Business') {
                        Link = Link + '#B';
                    }
                    console.log(date[2].pacsClass);
                }
            return Link;

但在浏览器URL中添加%23而不是#

angular
1个回答
0
投票

它只是通过url传递的编码数据。当你得到那个参数时,你仍然可以解码它,它将再次具有你已经传递的外观。默认情况下,Angular会对网址进行编码。对于未编码的网址,您需要编写自定义UrlSerializer。

有关更多信息,请参阅here

© www.soinside.com 2019 - 2024. All rights reserved.