NgbTab重装选项卡上的组件 [英] NgbTab reloading components on tab chage
问题描述
我有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屋!