【发布时间】:2026-02-17 23:25:01
【问题描述】:
我正在使用routerLink 从当前的component 导航到新的component
<div class="form-list-container">
<h3>Contact Form</h3>
<button md-raised-button routerLink="/add-form"
routerLinkActive="active">Add New</button>
<all-forms></all-forms>
<router-outlet></router-outlet>
</div>
单击Add New 按钮后,它会将/add-form 路由器组件视图呈现给
<router-outlet></router-outlet>
以及所有其他 HTML 元素。
编辑
对于路由,我有以下代码 -
const routes: Routes = [
{ path: '', redirectTo: '/home', pathMatch: 'full'},
{ path: 'home', component: AppComponent },
{ path: 'add-form', component: AddFormViewComponent },
]
当用户点击Add New 按钮时,我希望用户继续AddFormViewComponent 视图,而不是在当前component 中添加AddFormViewComponent 视图。
【问题讨论】:
-
然后把所有其他的 HTML 放到当前组件的视图中。
标签: angular