我有一些问题。 让我解释Angular2儿童路由
这是我的html代码
<div class="alert alert-danger alert-dismissable" *ngIf="errorMessage">
<a href="#" class="close" data-dismiss="alert" aria-label="close">×</a>
<strong>{{ errorMessage }}</strong>
</div>
<h3 class="page-header">All Unread Report</h3>
<table class="table table-hover">
<thead>
<tr>
<th>NIK</th>
<th>Nama</th>
<th>Topik</th>
<th>Detail</th>
</tr>
</thead>
<tbody>
<tr *ngFor="let item of allcomplaint;let i= index">
<td>{{i+1}}</td>
<td>{{item.sendername}}</td>
<td>{{item.topic}}</td>
<td>
<a class="btn btn-success" routerLink="/edit/{{item.id}}">Edit</a>
</td>
</tr>
</tbody>
</table>
我要的是,如果我点击编辑按钮链接,将导航到其他组件。但我总是得到错误这样下面
Uncaught (in promise): Error: Cannot match any routes. URL Segment: 'edit/1' Error: Cannot match any routes. URL Segment: 'edit/1
这是我的路由配置
{ path: 'dashboard_pool', component: DashboardPoolComponent,
children:[
{ path: 'unread', component: PoolUnreadReportComponent,
children:[
{path:'detail/:id', component:PoolComplaintDetailComponent}
]
},
如何解决这个问题?谢谢:)
你可以显示'edit'的路由配置吗? –
你的意思是我的路由配置?这是在我的问题。或者你的意思是编辑链接的组件? @SameerK – dedypuji
我猜你正在尝试的URL是'dashboard_pool/unread/edit/1',但是在'unread'的'children'下面,我没有在你的问题中看到'edit'的路由配置,只存在'detail' 。可能是因为你得到的错误.. –