ngbTabet切换到其他选项卡时不起作用

问题描述 投票:0回答:1

我正在使用ngbtabet(bootstrap 4.0)创建signinlogin选项卡。默认情况下,第一个标签页正在加载。当我单击第二个选项卡时,第二个选项卡未加载。

请提出我是否错过了任何依赖关系或错过了任何代码吗?

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 {
}

登录选项卡更改时未加载登录选项卡吗?

enter image description here

html angular bootstrap-4 angular-ui-bootstrap
1个回答
0
投票

您可以尝试这样:

<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>
© www.soinside.com 2019 - 2024. All rights reserved.