这是我的路由器代码:
const routes: Routes = [
{ path: '', component: IndexComponent},
{ path: 'microservice/:id', component: MicroserviceComponent}
];
我正在尝试通过加载这样的URL(获取请求)来从服务器加载端点
window.open("localhost:8080/api/login", "_self");
但是,如果我在主页(路径''
)中执行此操作,它将到达服务器,并且可以从服务器端看到它。如果我在microservice/bluh
页中运行此代码,则会显示主页,并且未单击登录端点。
路由是否存在问题,阻止了呼叫到服务器?
答案 0 :(得分:1)
将pathMatch:'full'添加到您的主要组件:
const routes: Routes = [
{ path: '', component: IndexComponent,pathMatch: 'full' },
{ path: 'microservice/:id', component: MicroserviceComponent}
];