【问题标题】:ng-bootstrap Tab inside another tab content is not working (angular 4)另一个选项卡内容中的 ng-bootstrap 选项卡不起作用(角度 4)
【发布时间】:2017-08-12 13:10:00
【问题描述】:

我有一个要求,我需要在另一个标签内容中创建一堆标签。当我将一组选项卡放入选项卡时,它会显示有线行为。

<ngb-tabset>
  <ngb-tab title="Simple">
    <ng-template ngbTabContent>
      <p>Raw denim you probably haven't heard of them jean shorts Austin. Nesciunt tofu stumptown aliqua, retro synth master cleanse. Mustache cliche tempor, williamsburg carles vegan helvetica. Reprehenderit butcher retro keffiyeh dreamcatcher synth. Cosby
        sweater eu banh mi, qui irure terry richardson ex squid. Aliquip placeat salvia cillum iphone. Seitan aliquip quis cardigan american apparel, butcher voluptate nisi qui.</p>


      <ngb-tabset>
        <ngb-tab title="tab12">
          <ng-template ngbTabContent>
            <p>Raw denim you probably haven't heard of them jean shorts Austin. Nesciunt tofu stumptown aliqua, retro synth master cleanse. Mustache cliche tempor, williamsburg carles vegan helvetica. Reprehenderit butcher retro keffiyeh dreamcatcher synth.
              Cosby sweater eu banh mi, qui irure terry richardson ex squid. Aliquip placeat salvia cillum iphone. Seitan aliquip quis cardigan american apparel, butcher voluptate nisi qui.</p>
          </ng-template>
        </ngb-tab>

        <ngb-tab title="tab2 disabled">
          <ng-template ngbTabContent>
            <p>Raw denim you probably haven't heard of them jean shorts Austin. Nesciunt tofu stumptown aliqua, retro synth master cleanse. Mustache cliche tempor, williamsburg carles vegan helvetica. Reprehenderit butcher retro keffiyeh dreamcatcher synth.
              Cosby sweater eu banh mi, qui irure terry richardson ex squid. Aliquip placeat salvia cillum iphone. Seitan aliquip quis cardigan american apparel, butcher voluptate nisi qui.</p>
          </ng-template>
        </ngb-tab>
      </ngb-tabset>

    </ng-template>
  </ngb-tab>
  <ngb-tab>
    <ng-template ngbTabTitle><b>Fancy</b> title</ng-template>
    <ng-template ngbTabContent>Food truck fixie locavore, accusamus mcsweeney's marfa nulla single-origin coffee squid.
      <p>Exercitation +1 labore velit, blog sartorial PBR leggings next level wes anderson artisan four loko farm-to-table craft beer twee. Qui photo booth letterpress, commodo enim craft beer mlkshk aliquip jean shorts ullamco ad vinyl cillum PBR. Homo
        nostrud organic, assumenda labore aesthetic magna delectus mollit. Keytar helvetica VHS salvia yr, vero magna velit sapiente labore stumptown. Vegan fanny pack odio cillum wes anderson 8-bit, sustainable jean shorts beard ut DIY ethical culpa
        terry richardson biodiesel. Art party scenester stumptown, tumblr butcher vero sint qui sapiente accusamus tattooed echo park.</p>
    </ng-template>
  </ngb-tab>
  <ngb-tab title="Disabled" [disabled]="true">
    <ng-template ngbTabContent>
      <p>Raw denim you probably haven't heard of them jean shorts Austin. Nesciunt tofu stumptown aliqua, retro synth master cleanse. Mustache cliche tempor, williamsburg carles vegan helvetica. Reprehenderit butcher retro keffiyeh dreamcatcher synth. Cosby
        sweater eu banh mi, qui irure terry richardson ex squid. Aliquip placeat salvia cillum iphone. Seitan aliquip quis cardigan american apparel, butcher voluptate nisi qui.</p>
    </ng-template>
  </ngb-tab>
</ngb-tabset>

http://plnkr.co/edit/Nw9utaWLYwmbhQW2OMLb?p=preview

在 plunker 中,第一个选项卡内容中的选项卡将不可见,直到您单击选项卡的标题,如果您单击另一个选项卡,则子选项卡将不再可见。

  • 角度:4.1.3
  • ng-bootstrap: 1.0.0-alpha.26
  • 引导程序:4.0.0-alpha.6

【问题讨论】:

    标签: angular ng-bootstrap


    【解决方案1】:

    我认为当您将 TemplateRef 等实例用作直接子项时,它们会混合在选项卡中。我会使用ngTemplateOutlet 来完成它:

    <ngb-tabset>
      <ngb-tab title="Simple">
        <ng-template ngbTabContent>
          <p>Some content</p>
    
         <ng-container *ngTemplateOutlet="innerTabset"></ng-container>
      </ngb-tab>
      ...
    </ngb-tabset>
    
    <ng-template #innerTabset>
      <ngb-tabset>
        ... tabs content
      </ngb-tabset>
    </ng-template>
    

    Plunker Example

    另见

    【讨论】:

      猜你喜欢
      • 2018-07-13
      • 2021-07-19
      • 2014-09-13
      • 2020-06-16
      • 2019-10-20
      • 1970-01-01
      • 2016-12-11
      • 2018-07-08
      • 1970-01-01
      相关资源
      最近更新 更多