NgbTab重装选项卡上的组件 [英] NgbTab reloading components on tab chage

查看:336
本文介绍了NgbTab重装选项卡上的组件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有2个选项卡,并且在选项卡内容内有一个我开发的组件.每当我从一个选项卡移动到另一个选项卡并返回放置开发组件所在的选项卡时,它都会重新加载并调用其生命周期方法,这对我造成了问题.

I have 2 tabs and inside the tab content there is a component i developed. When ever I move from one tab to another and come back to the tab on which my developed component is place, it reloads and calls its lifecycle methods called which causing problem for me.

有没有一种方法可以在更改选项卡时停止重新加载组件.

Is there a way to stop reloading the component on change of the tab.

<ngb-tabset>
    <ngb-tab title="xyz..." id="overview">
        <ng-template ngbTabContent>
            ...
            <sd-tags [existingTags]="tags" [somethingelse]="otherstuffs" [more]="morestuff"></sd-tags>
            ...
        </ng-template>
    </ngb-tab>
    <ngb-tab [title]="sothingesele" id="columns">
        <ng-template ngbTabContent>
            ...
        </ng-template>
    </ngb-tab>
</ngb-tabset>

当标签改变时,组件重载并什么都被处理时,它涉及到初始阶段和造成问题.

When tab changed, the sd-tabs component reloads and what ever is processed, it comes to initial stage and causing problem.

推荐答案

我想您正在寻找ngb-tabset上的destroyOnHide输入属性:

I guess you are looking for destroyOnHide input property on ngb-tabset:

<ngb-tabset [destroyOnHide]="false">
  ...
</ngb-tabset>

根据 文档

According to the docs

destroyOnHide

默认值:true

关闭的标签页是否应隐藏而不 摧毁他们

Whether the closed tabs should be hidden without destroying them

柱塞示例

Plunker Example

这篇关于NgbTab重装选项卡上的组件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆