我正在使用ngbtabet(bootstrap 4.0)创建signin和login选项卡。默认情况下,第一个标签页正在加载。当我单击第二个选项卡时,第二个选项卡未加载。
请提出我是否错过了任何依赖关系或错过了任何代码吗?
1)signin-Container.component.html
<div class="row">
<ngb-tabset #tabset>
<ngb-tab id="tab1" title="Signin">
<ng-template ngbTabContent>
<p>Signin elements loads here</p>
</ng-template>
</ngb-tab>
<ngb-tab id="tab2"
title="Login">
<ng-template ngbTabContent>
<p> Login elements loads here</p>
</ng-template>
</ngb-tab>
</ngb-tabset>
</div>
2)signin-container.component.ts
import { Component, OnInit, ViewChild } from '@angular/core';
import { NgbTabChangeEvent, NgbTabset } from '@ng-bootstrap/ng-bootstrap';
@Component({
selector: "signin-container",
templateUrl: "./signin-container.component.html",
styleUrls: ["./signin-container.component.scss"]
})
export class SigninContainerComponent implements OnInit {
constructor() {}
ngOnInit() {}
}
3)app.module.ts
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
import { SigninContainerComponent } from './signin-container.component';
@NgModule({
declarations: [
SigninContainerComponent
],
imports: [
NgbModule,
FormsModule,
ReactiveFormsModule,
BrowserModule,
]
export class AppModule implements DoBootstrap {
}
登录选项卡更改时未加载登录选项卡吗?
您可以尝试这样:
<ngb-tabset #tabset>
<ngb-tab id="tab1" title="Signin">
<ng-template ngbTabContent>
<app-signin-container></app-signin-container>
</ng-template>
</ngb-tab>
<ngb-tab id="tab2" title="Login">
<ng-template ngbTabContent>
<app-login-container></app-login-container>
</ng-template>
</ngb-tab>
</ngb-tabset>