I develop an application using angular. In my application there is two kinds of path:
type 1:
- http://localhost:4203/121/index (121 is merchant id)
- http://localhost:4203/121/bill/tci
- http://localhost:4203/121/bill/mci
- http://localhost:4203/121/profile/dashboard
type 2:
- http://localhost:4203/index (default without merchant id)
- http://localhost:4203/bill/tci
- http://localhost:4203/bill/mci
- http://localhost:4203/profile/dashboard
so I did below code in app-routing Module:
export const routes: Routes = [
{
path: 'profile',
loadChildren: () => import('./pages/profile/profile.module')
.then(m => m.ProfileModule),
},
{
path: ':mid/profile',
loadChildren: () => import('./pages/profile/profile.module')
.then(m => m.ProfileModule),
},
{
path: 'bill',
loadChildren: () => import('./pages/bill/bill.module')
.then(m => m.BillModule),
},
{
path: ':mid/bill',
loadChildren: () => import('./pages/bill/bill.module')
.then(m => m.BillModule),
},
{
path: 'index',
component: IndexComponent,
},
{
path: ':mid/index',
component: IndexComponent,
},
{
path: 'auth-callback',
component: AuthCallBackComponent,
},
{ path: '', redirectTo: 'index', pathMatch: 'full' },
{ path: '**', redirectTo: 'pages' },
];
I created some library component on another project and it is added to this project. here is my card component:
<div class="solution_card">
<a [routerLink]="defaullink">
<div class="hover_color_bubble"></div>
<a *ngFor="let icon of defaultMenu.icons" [routerLink]="icon.link" class="float-start icons">
<i [class]="icon.title"></i>
</a>
<div class="so_top_icon">
<img [src]="defaultMenu.img" />
</div>
<div class="solu_title">
<h3>{{defaultMenu.title}}</h3>
</div>
<div class="solu_description">
<p>
{{defaultMenu.subTitle}}
</p>
</div>
</a>
</div>
and in component module I defined default links:
public defaullink:string = '../test2';
public defaullink2:string = '../123231321';
when I used this component in my project, I expect results as below:
(I put component in index.html.ts)
- in Page: http://localhost:4203/121/index ===> link to: http://localhost:4203/121/test2
- in Page: http://localhost:4203/index ===> link to: http://localhost:4203/test2
but in both pages the link is: http://localhost:4203/test2
please help me