首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >主路由器出口内部的二次路由器出口不能工作

主路由器出口内部的二次路由器出口不能工作
EN

Stack Overflow用户
提问于 2018-12-21 14:22:49
回答 2查看 73关注 0票数 0

对于我的路由器,我有以下配置。次要路由器出口包含在主路由器中。当我尝试使用routerLink来显示roster.component.html时,它会抛出以下错误:我尝试了许多不同的配置,但我不明白为什么它不能工作。

错误错误:" object“resolvePromise http://localhost:4200/polyfills.js:3159:31 resolvePromise http://localhost:4200/polyfills.js:3116:17 scheduleResolveOrReject http://localhost:4200/polyfills.js:3218:17 invokeTask http://localhost:4200/polyfills.js:2766:17 onInvokeTask http://localhost:4200/vendor.js:73499:24 invokeTask http://localhost:4200/polyfills.js:2765:17 runTask http://localhost:4200/polyfills.js:2533:28 http://localhost:4200/polyfills.js:2533:28 drainMicroTaskQueue http://localhost:4200/polyfills.js:2940:25 invokeTask http://localhost:4200/polyfills.js:2845:21 http://localhost:4200/polyfills.js:3885:9 http://localhost:4200/polyfills.js:3911:17

app.module.ts

代码语言:javascript
复制
import { RouterModule, Routes } from '@angular/router';
const appRoutes: Routes = [

  {path: '', component: ProfileComponent},
    {path: 'roster', component: RosterComponent, outlet: 'basis'},

  /*
  {path: '', component: ProfileComponent,children: [
    {path: 'roster', component: RosterComponent, outlet: 'basis'},
  ]}
*/
]
@NgModule({
  declarations: [
    AppComponent,
    MainViewComponent,
    ProfileComponent,
    RosterComponent
  ],
  imports: [
    BrowserModule,
    BrowserAnimationsModule,
    RouterModule.forRoot(appRoutes),
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }

main-view.component.html

代码语言:javascript
复制
  <router-outlet></router-outlet>

profile.component.html

代码语言:javascript
复制
<a [routerLink]="[{ outlets:{ primery:['],basis: ['roster'] } }]">GO</a>
 <router-outlet name="basis"></router-outlet>
EN

回答 2

Stack Overflow用户

发布于 2018-12-21 15:10:57

看上去你有一些排字,试试这个:

代码语言:javascript
复制
<a [routerLink]="[{ outlets: { primary: [''],basis: ['roster'] } }]">
    Go
</a>
票数 1
EN

Stack Overflow用户

发布于 2018-12-21 15:09:57

路由器配置:

代码语言:javascript
复制
{ path: '', component: ProfileComponent,
    children: [
      { path: 'roster', component: RosterComponent, },
    ]
  }

app.component.html或main-view.component.html

代码语言:javascript
复制
<a routerLink="/roster">Go</a>

profile.component.html

代码语言:javascript
复制
<router-outlet></router-outlet>
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/53886353

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档