【发布时间】:2019-05-17 11:55:12
【问题描述】:
我有 ngtabcontent,所以它的内容应该是动态的,所以为 PersonalComponent 创建子路由,现在点击下一个它应该导航到它的子路由。
const routes: { path: '', redirectTo: 'tenant', pathMatch: '{ path: "personal", component: children: [
{ path: 'employer', component: AddemployerComponent, outlet: 'test'},
]
},
{ path: "applicant", component: AddapplicantComponent },
{ path: 'tenant', component: TenantappComponent },
{ path: 'animal', component: AddanimalComponent },
{ path: 'vehicle', component: AddvehiclesComponent },
{ path: 'background-info', component: BackgroundInfoComponent },
{ path: 'termsandconditions', component: TermsandconditionsComponent },
{ path: 'payment', component: PaymentComponent }
];
所以这是我的路由模块,最初我会在其中显示我的个人组件,然后单击它应该导航具有插座名称的子路由雇主。
nextFn() {
if (this.router.url === '/personal') {
this.router.navigate(['employer', {outlets: 'test'}]);
this.shared.isSubmitPayment = true;
} else if (this.router.url === '/employer') {
this.router.navigate(['animal']);
} else if (this.router.url === '/animal') {
this.router.navigate(['vehicle']);
} else if (this.router.url === '/vehicle') {
this.router.navigate(['background-info']);
} else if (this.router.url === '/background-info') {
this.router.navigate(['termsandconditions']);
} else if (this.router.url === '/termsandconditions') {
this.router.navigate(['payment']);
}}
在组件文件中,我的路线是这样的..
<div class="row personal-info">
<div class="input-group">
<div class="input-group-prepend">
<div class="input-group-text" id="btnGroupAddon"><i class="fa fa-check" aria-hidden="true"></i></div>
</div>
<p class="registration"><b>Registration Successful</b></p>
</div>
</div>
<app-tenant-header></app-tenant-header>
<div class="form-feilds">
<h6>Personal Information</h6>
<ngb-tabset>
<ngb-tab [id]="tab.id" *ngFor="let tab of tabs;let i = index;">
<ng-template ngbTabTitle>
{{tab.title}}{{applicantNumberArray[i - 1]}}
</ng-template>
<ng-template ngbTabContent>
<div *ngIf="!shared.isSubmitPayment">
<app-formfields [personalInfo]=personalInfo [tabIndex]=i [tabs]=tabs (addApplication)="addApplicantFn($event)" (deleteApplication)="deleteApplicantFn($event)"></app-formfields>
</div>
<div *ngIf="shared.isSubmitPayment">
<router-outlet></router-outlet>
</div>
</ng-template>
</ngb-tab>
</ngb-tabset>
</div>
<div class="col-md-12 col-sm-12 col-xs-12 property-footer">
<app-footer></app-footer>
</div>
我的html是这样的......
提前致谢
【问题讨论】:
标签: angular angular2-routing angular-routing