在我的Angular 6项目中,我有一些带侧边栏的组件,其中一些没有。我尝试用辅助路线做到这一点并且它有效,但URL很难看......!
-
我的所作所为:
const routes: Routes = [
{
path: 'login',
component: LoginComponent
},
{
path: 'search',
component: SearchComponent
},
{
path: 'sidebar',
outlet: 'sidebar',
component: SidebarComponent
}
这给了我们可能的网址
https://localhost:4200/login - (login without sidebar)
https://localhost:4200/login(sidebar:sidebar) - (login with sidebar)
https://localhost:4200/search - (search without sidebar)
https://localhost:4200/search(sidebar:sidebar) - (search with sidebar)
-
所需的结果只是拥有网址/登录和/搜索,但使用侧边栏和没有侧边栏的登录进行搜索。 我该怎么做?
辅助路线是否是正确的方法?或者还有另一种方法可以做到这一点吗?