UNPKG

carbon-components-angular

Version:
1,256 lines (1,122 loc) 63.8 kB
<!doctype html> <html class="no-js" lang=""> <head> <meta charset="utf-8"> <meta http-equiv="x-ua-compatible" content="ie=edge"> <title>carbon-components-angular documentation</title> <meta name="description" content=""> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="icon" type="image/x-icon" href="../images/favicon.ico"> <link rel="stylesheet" href="../styles/style.css"> <link rel="stylesheet" href="../styles/dark.css"> <style> footer.carbon { position: absolute; bottom: 0; width: 100%; z-index: 9999; } #root > div { /* * Subtracting the height of the footer to prevent * overlaying the footer ontop of content */ height: calc(100vh - 48px); } </style> </head> <body> <script> // Blocking script to avoid flickering dark mode // Dark mode toggle button var useDark = window.matchMedia('(prefers-color-scheme: dark)'); var darkModeState = useDark.matches; var $darkModeToggleSwitchers = document.querySelectorAll('.dark-mode-switch input'); var $darkModeToggles = document.querySelectorAll('.dark-mode-switch'); var darkModeStateLocal = localStorage.getItem('compodoc_darkmode-state'); function checkToggle(check) { for (var i = 0; i < $darkModeToggleSwitchers.length; i++) { $darkModeToggleSwitchers[i].checked = check; } } function toggleDarkMode(state) { if (window.localStorage) { localStorage.setItem('compodoc_darkmode-state', state); } checkToggle(state); const hasClass = document.body.classList.contains('dark'); if (state) { for (var i = 0; i < $darkModeToggles.length; i++) { $darkModeToggles[i].classList.add('dark'); } if (!hasClass) { document.body.classList.add('dark'); } } else { for (var i = 0; i < $darkModeToggles.length; i++) { $darkModeToggles[i].classList.remove('dark'); } if (hasClass) { document.body.classList.remove('dark'); } } } useDark.addEventListener('change', function (evt) { toggleDarkMode(evt.matches); }); if (darkModeStateLocal) { darkModeState = darkModeStateLocal === 'true'; } toggleDarkMode(darkModeState); </script> <div class="navbar navbar-default navbar-fixed-top d-md-none p-0"> <div class="d-flex"> <a href="../" class="navbar-brand">carbon-components-angular documentation</a> <button type="button" class="btn btn-default btn-menu ion-ios-menu" id="btn-menu"></button> </div> </div> <div class="xs-menu menu" id="mobile-menu"> <div id="book-search-input" role="search"><input type="text" placeholder="Type to search"></div> <compodoc-menu></compodoc-menu> </div> <div class="container-fluid main"> <div class="row main"> <div class="d-none d-md-block menu"> <compodoc-menu mode="normal"></compodoc-menu> </div> <!-- START CONTENT --> <div class="content component"> <div class="content-data"> <ol class="breadcrumb"> <li class="breadcrumb-item">Components</li> <li class="breadcrumb-item" > Tab</li> </ol> <ul class="nav nav-tabs" role="tablist"> <li class="nav-item"> <a href="#info" class="nav-link active" role="tab" id="info-tab" data-bs-toggle="tab" data-link="info">Info</a> </li> <li class="nav-item"> <a href="#source" class="nav-link" role="tab" id="source-tab" data-bs-toggle="tab" data-link="source">Source</a> </li> <li class="nav-item"> <a href="#tree" class="nav-link" role="tab" id="tree-tab" data-bs-toggle="tab" data-link="dom-tree">DOM Tree</a> </li> </ul> <div class="tab-content"> <div class="tab-pane fade active in" id="info"><p class="comment"> <h3>File</h3> </p> <p class="comment"> <code>src/tabs/tab.component.ts</code> </p> <p class="comment"> <h3>Description</h3> </p> <p class="comment"> <p>The <code>Tab</code> component is a child of the <code>Tabs</code> component. It represents one <code>Tab</code> item and its content within a panel of other <code>Tab</code> items.</p> <p><code>Tab</code> takes a string or <code>TemplateRef</code> for the header, and any content for the body of the tab. Disabled states should be handled by the application (ie. switch to the tab, but display some indication as to <em>why</em> the tab is disabled).</p> <p>When the tab is selected the <code>select</code> output will be triggered. The <code>select</code> output will also be triggered for the active tab when the tabs are loaded or updated.</p> <p>Tab with string header:</p> <b>Example :</b><div><pre class="line-numbers"><code class="language-html">&lt;cds-tab heading=&#39;tab1&#39;&gt; tab 1 content &lt;/cds-tab&gt;</code></pre></div><p>Tab with custom header:</p> <b>Example :</b><div><pre class="line-numbers"><code class="language-html">&lt;ng-template #tabHeading&gt; &lt;svg cdsIcon=&quot;facebook&quot; size=&quot;sm&quot; style=&quot;margin-right: 7px;&quot;&gt; &lt;/svg&gt; Hello Tab 1 &lt;/ng-template&gt; &lt;cds-tabs&gt; &lt;cds-tab [heading]=&quot;tabHeading&quot;&gt; Tab 1 content &lt;svg cdsIcon=&quot;alert&quot; size=&quot;lg&quot;&gt;&lt;/svg&gt; &lt;/cds-tab&gt; &lt;cds-tab heading=&#39;Tab2&#39;&gt; Tab 2 content &lt;/cds-tab&gt; &lt;cds-tab heading=&#39;Tab3&#39;&gt; Tab 3 content &lt;/cds-tab&gt; &lt;/cds-tabs&gt;</code></pre></div> </p> <p class="comment"> <h3>Implements</h3> </p> <p class="comment"> <code>OnInit</code> </p> <section data-compodoc="block-metadata"> <h3>Metadata</h3> <table class="table table-sm table-hover metadata"> <tbody> <tr> <td class="col-md-3">selector</td> <td class="col-md-9"><code>cds-tab, ibm-tab</code></td> </tr> <tr> <td class="col-md-3">template</td> <td class="col-md-9"><pre class="line-numbers"><code class="language-html">&lt;div [attr.tabindex]&#x3D;&quot;tabIndex&quot; role&#x3D;&quot;tabpanel&quot; *ngIf&#x3D;&quot;shouldRender()&quot; class&#x3D;&quot;cds--tab-content&quot; [id]&#x3D;&quot;id&quot; [ngStyle]&#x3D;&quot;{&#x27;display&#x27;: active ? null : &#x27;none&#x27;}&quot; [attr.aria-labelledby]&#x3D;&quot;id + &#x27;-header&#x27;&quot; aria-live&#x3D;&quot;polite&quot;&gt; &lt;ng-template *ngIf&#x3D;&quot;isTemplate(tabContent)&quot; [ngTemplateOutlet]&#x3D;&quot;tabContent&quot; [ngTemplateOutletContext]&#x3D;&quot;{ $implicit: templateContext }&quot;&gt; &lt;/ng-template&gt; &lt;ng-content&gt;&lt;/ng-content&gt; &lt;/div&gt; </code></pre></td> </tr> </tbody> </table> </section> <section data-compodoc="block-index"> <h3 id="index">Index</h3> <table class="table table-sm table-bordered index-table"> <tbody> <tr> <td class="col-md-4"> <h6><b>Properties</b></h6> </td> </tr> <tr> <td class="col-md-4"> <ul class="index-list"> <li> <span class="modifier">Protected</span> <a href="#_cacheActive" >_cacheActive</a> </li> <li> <span class="modifier">Private</span> <span class="modifier">Static</span> <a href="#counter" >counter</a> </li> <li> <span class="modifier">Public</span> <a href="#headingIsTemplate" >headingIsTemplate</a> </li> </ul> </td> </tr> <tr> <td class="col-md-4"> <h6><b>Methods</b></h6> </td> </tr> <tr> <td class="col-md-4"> <ul class="index-list"> <li> <a href="#doSelect" >doSelect</a> </li> <li> <span class="modifier">Public</span> <a href="#isTemplate" >isTemplate</a> </li> <li> <a href="#ngOnInit" >ngOnInit</a> </li> <li> <a href="#shouldRender" >shouldRender</a> </li> </ul> </td> </tr> <tr> <td class="col-md-4"> <h6><b>Inputs</b></h6> </td> </tr> <tr> <td class="col-md-4"> <ul class="index-list"> <li> <a href="#active" >active</a> </li> <li> <a href="#cacheActive" >cacheActive</a> </li> <li> <a href="#context" >context</a> </li> <li> <a href="#disabled" >disabled</a> </li> <li> <a href="#heading" >heading</a> </li> <li> <a href="#id" >id</a> </li> <li> <a href="#tabContent" >tabContent</a> </li> <li> <a href="#tabIndex" >tabIndex</a> </li> <li> <a href="#templateContext" >templateContext</a> </li> <li> <a href="#title" >title</a> </li> </ul> </td> </tr> <tr> <td class="col-md-4"> <h6><b>Outputs</b></h6> </td> </tr> <tr> <td class="col-md-4"> <ul class="index-list"> <li> <a href="#selected" >selected</a> </li> </ul> </td> </tr> <tr> <td class="col-md-4"> <h6><b>Accessors</b></h6> </td> </tr> <tr> <td class="col-md-4"> <ul class="index-list"> <li> <a href="#cacheActive" >cacheActive</a> </li> </ul> </td> </tr> </tbody> </table> </section> <section data-compodoc="block-inputs"> <h3 id="inputs">Inputs</h3> <table class="table table-sm table-bordered"> <tbody> <tr> <td class="col-md-4"> <a name="active"></a> <b>active</b> </td> </tr> <tr> <td class="col-md-4"> <i>Type : </i> <code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/boolean" target="_blank" >boolean</a></code> </td> </tr> <tr> <td class="col-md-4"> <i>Default value : </i><code>false</code> </td> </tr> <tr> <td class="col-md-2" colspan="2"> <div class="io-line">Defined in <a href="" data-line="103" class="link-to-prism">src/tabs/tab.component.ts:103</a></div> </td> </tr> <tr> <td class="col-md-4"> <div class="io-description"><p>Indicates whether the <code>Tab</code> is active/selected. Determines whether it&#39;s <code>TabPanel</code> is rendered.</p> </div> </td> </tr> </tbody> </table> <table class="table table-sm table-bordered"> <tbody> <tr> <td class="col-md-4"> <a name="cacheActive"></a> <b>cacheActive</b> </td> </tr> <tr> <td class="col-md-4"> <i>Type : </i> <code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/boolean" target="_blank" >boolean</a></code> </td> </tr> <tr> <td class="col-md-2" colspan="2"> <div class="io-line">Defined in <a href="" data-line="117" class="link-to-prism">src/tabs/tab.component.ts:117</a></div> </td> </tr> <tr> <td class="col-md-4"> <div class="io-description"><p>Set to true to have Tab items cached and not reloaded on tab switching.</p> </div> </td> </tr> </tbody> </table> <table class="table table-sm table-bordered"> <tbody> <tr> <td class="col-md-4"> <a name="context"></a> <b>context</b> </td> </tr> <tr> <td class="col-md-4"> <i>Type : </i> <code><a href="https://www.typescriptlang.org/docs/handbook/basic-types.html" target="_blank" >any</a></code> </td> </tr> <tr> <td class="col-md-2" colspan="2"> <div class="io-line">Defined in <a href="" data-line="98" class="link-to-prism">src/tabs/tab.component.ts:98</a></div> </td> </tr> <tr> <td class="col-md-4"> <div class="io-description"><p>Allows the user to pass data to the custom template for the <code>Tab</code> heading.</p> </div> </td> </tr> </tbody> </table> <table class="table table-sm table-bordered"> <tbody> <tr> <td class="col-md-4"> <a name="disabled"></a> <b>disabled</b> </td> </tr> <tr> <td class="col-md-4"> <i>Type : </i> <code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/boolean" target="_blank" >boolean</a></code> </td> </tr> <tr> <td class="col-md-4"> <i>Default value : </i><code>false</code> </td> </tr> <tr> <td class="col-md-2" colspan="2"> <div class="io-line">Defined in <a href="" data-line="107" class="link-to-prism">src/tabs/tab.component.ts:107</a></div> </td> </tr> <tr> <td class="col-md-4"> <div class="io-description"><p>Indicates whether or not the <code>Tab</code> item is disabled.</p> </div> </td> </tr> </tbody> </table> <table class="table table-sm table-bordered"> <tbody> <tr> <td class="col-md-4"> <a name="heading"></a> <b>heading</b> </td> </tr> <tr> <td class="col-md-4"> <i>Type : </i> <code>string | TemplateRef&lt;any&gt;</code> </td> </tr> <tr> <td class="col-md-2" colspan="2"> <div class="io-line">Defined in <a href="" data-line="87" class="link-to-prism">src/tabs/tab.component.ts:87</a></div> </td> </tr> <tr> <td class="col-md-4"> <div class="io-description"><p>The <code>Tab</code>&#39;s title to be displayed or custom temaplate for the <code>Tab</code> heading.</p> </div> </td> </tr> </tbody> </table> <table class="table table-sm table-bordered"> <tbody> <tr> <td class="col-md-4"> <a name="id"></a> <b>id</b> </td> </tr> <tr> <td class="col-md-4"> <i>Type : </i> <code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/string" target="_blank" >string</a></code> </td> </tr> <tr> <td class="col-md-4"> <i>Default value : </i><code>&#x60;n-tab-${Tab.counter++}&#x60;</code> </td> </tr> <tr> <td class="col-md-2" colspan="2"> <div class="io-line">Defined in <a href="" data-line="113" class="link-to-prism">src/tabs/tab.component.ts:113</a></div> </td> </tr> <tr> <td class="col-md-4"> <div class="io-description"><p>Sets the id of the <code>Tab</code>. Will be uniquely generated if not provided.</p> </div> </td> </tr> </tbody> </table> <table class="table table-sm table-bordered"> <tbody> <tr> <td class="col-md-4"> <a name="tabContent"></a> <b>tabContent</b> </td> </tr> <tr> <td class="col-md-4"> <i>Type : </i> <code>TemplateRef&lt;any&gt;</code> </td> </tr> <tr> <td class="col-md-2" colspan="2"> <div class="io-line">Defined in <a href="" data-line="123" class="link-to-prism">src/tabs/tab.component.ts:123</a></div> </td> </tr> <tr> <td class="col-md-4"> <div class="io-description"><p>Allows life cycle hooks to be called on the rendered content</p> </div> </td> </tr> </tbody> </table> <table class="table table-sm table-bordered"> <tbody> <tr> <td class="col-md-4"> <a name="tabIndex"></a> <b>tabIndex</b> </td> </tr> <tr> <td class="col-md-4"> <i>Type : </i> <code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/number" target="_blank" >number</a></code> </td> </tr> <tr> <td class="col-md-4"> <i>Default value : </i><code>0</code> </td> </tr> <tr> <td class="col-md-2" colspan="2"> <div class="io-line">Defined in <a href="" data-line="109" class="link-to-prism">src/tabs/tab.component.ts:109</a></div> </td> </tr> </tbody> </table> <table class="table table-sm table-bordered"> <tbody> <tr> <td class="col-md-4"> <a name="templateContext"></a> <b>templateContext</b> </td> </tr> <tr> <td class="col-md-4"> <i>Type : </i> <code><a href="https://www.typescriptlang.org/docs/handbook/basic-types.html" target="_blank" >any</a></code> </td> </tr> <tr> <td class="col-md-2" colspan="2"> <div class="io-line">Defined in <a href="" data-line="127" class="link-to-prism">src/tabs/tab.component.ts:127</a></div> </td> </tr> <tr> <td class="col-md-4"> <div class="io-description"><p>Optional data for templates passed as implicit context</p> </div> </td> </tr> </tbody> </table> <table class="table table-sm table-bordered"> <tbody> <tr> <td class="col-md-4"> <a name="title"></a> <b>title</b> </td> </tr> <tr> <td class="col-md-4"> <i>Type : </i> <code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/string" target="_blank" >string</a></code> </td> </tr> <tr> <td class="col-md-2" colspan="2"> <div class="io-line">Defined in <a href="" data-line="94" class="link-to-prism">src/tabs/tab.component.ts:94</a></div> </td> </tr> <tr> <td class="col-md-4"> <div class="io-description"><p>Optional override for the <code>tabItem&#39;s</code>&#39;s title attribute which is set in <code>TabHeaders</code>. <code>tabItem</code>&#39;s title attribute is automatically set to <code>heading</code>.</p> <p>You might want to use this if you set <code>heading</code> to a <code>TemplateRef</code>.</p> </div> </td> </tr> </tbody> </table> </section> <section data-compodoc="block-outputs"> <h3 id="outputs">Outputs</h3> <table class="table table-sm table-bordered"> <tbody> <tr> <td class="col-md-4"> <a name="selected"></a> <b>selected</b> </td> </tr> <tr> <td class="col-md-4"> <i>Type : </i> <code>EventEmitter&lt;void&gt;</code> </td> </tr> <tr> <td class="col-md-2" colspan="2"> <div class="io-line">Defined in <a href="" data-line="131" class="link-to-prism">src/tabs/tab.component.ts:131</a></div> </td> </tr> <tr> <td class="col-md-4"> <div class="io-description"><p>Value &#39;selected&#39; to be emitted after a new <code>Tab</code> is selected.</p> </div> </td> </tr> </tbody> </table> </section> <section data-compodoc="block-methods"> <h3 id="methods"> Methods </h3> <table class="table table-sm table-bordered"> <tbody> <tr> <td class="col-md-4"> <a name="doSelect"></a> <span class="name"> <span ><b>doSelect</b></span> <a href="#doSelect"><span class="icon ion-ios-link"></span></a> </span> </td> </tr> <tr> <td class="col-md-4"> <code>doSelect()</code> </td> </tr> <tr> <td class="col-md-4"> <div class="io-line">Defined in <a href="" data-line="152" class="link-to-prism">src/tabs/tab.component.ts:152</a></div> </td> </tr> <tr> <td class="col-md-4"> <div class="io-description"><p>Emit the status of the <code>Tab</code>, specifically &#39;select&#39; and &#39;selected&#39; properties.</p> </div> <div class="io-description"> <b>Returns : </b> <code><a href="https://www.typescriptlang.org/docs/handbook/basic-types.html" target="_blank" >void</a></code> </div> </td> </tr> </tbody> </table> <table class="table table-sm table-bordered"> <tbody> <tr> <td class="col-md-4"> <a name="isTemplate"></a> <span class="name"> <span class="modifier">Public</span> <span ><b>isTemplate</b></span> <a href="#isTemplate"><span class="icon ion-ios-link"></span></a> </span> </td> </tr> <tr> <td class="col-md-4"> <span class="modifier-icon icon ion-ios-reset"></span> <code>isTemplate(value)</code> </td> </tr> <tr> <td class="col-md-4"> <div class="io-line">Defined in <a href="" data-line="163" class="link-to-prism">src/tabs/tab.component.ts:163</a></div> </td> </tr> <tr> <td class="col-md-4"> <div class="io-description"> <b>Parameters :</b> <table class="params"> <thead> <tr> <td>Name</td> <td>Optional</td> </tr> </thead> <tbody> <tr> <td>value</td> <td> No </td> </tr> </tbody> </table> </div> <div class="io-description"> <b>Returns : </b> <code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/boolean" target="_blank" >boolean</a></code> </div> <div class="io-description"> </div> </td> </tr> </tbody> </table> <table class="table table-sm table-bordered"> <tbody> <tr> <td class="col-md-4"> <a name="ngOnInit"></a> <span class="name"> <span ><b>ngOnInit</b></span> <a href="#ngOnInit"><span class="icon ion-ios-link"></span></a> </span> </td> </tr> <tr> <td class="col-md-4"> <code>ngOnInit()</code> </td> </tr> <tr> <td class="col-md-4"> <div class="io-line">Defined in <a href="" data-line="143" class="link-to-prism">src/tabs/tab.component.ts:143</a></div> </td> </tr> <tr> <td class="col-md-4"> <div class="io-description"><p>Checks for custom heading template on initialization and updates the value of the boolean &#39;headingIsTemplate&#39;.</p> </div> <div class="io-description"> <b>Returns : </b> <code><a href="https://www.typescriptlang.org/docs/handbook/basic-types.html" target="_blank" >void</a></code> </div> </td> </tr> </tbody> </table> <table class="table table-sm table-bordered"> <tbody> <tr> <td class="col-md-4"> <a name="shouldRender"></a> <span class="name"> <span ><b>shouldRender</b></span> <a href="#shouldRender"><span class="icon ion-ios-link"></span></a> </span> </td> </tr> <tr> <td class="col-md-4"> <code>shouldRender()</code> </td> </tr> <tr> <td class="col-md-4"> <div class="io-line">Defined in <a href="" data-line="159" class="link-to-prism">src/tabs/tab.component.ts:159</a></div> </td> </tr> <tr> <td class="col-md-4"> <div class="io-description"><p>Returns value indicating whether this <code>Tab</code> should be rendered in a <code>TabPanel</code>.</p> </div> <div class="io-description"> <b>Returns : </b> <code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/boolean" target="_blank" >boolean</a></code> </div> </td> </tr> </tbody> </table> </section> <section data-compodoc="block-properties"> <h3 id="inputs"> Properties </h3> <table class="table table-sm table-bordered"> <tbody> <tr> <td class="col-md-4"> <a name="_cacheActive"></a> <span class="name"> <span class="modifier">Protected</span> <span ><b>_cacheActive</b></span> <a href="#_cacheActive"><span class="icon ion-ios-link"></span></a> </span> </td> </tr> <tr> <td class="col-md-4"> <i>Default value : </i><code>false</code> </td> </tr> <tr> <td class="col-md-4"> <div class="io-line">Defined in <a href="" data-line="137" class="link-to-prism">src/tabs/tab.component.ts:137</a></div> </td> </tr> </tbody> </table> <table class="table table-sm table-bordered"> <tbody> <tr> <td class="col-md-4"> <a name="counter"></a> <span class="name"> <span class="modifier">Private</span> <span class="modifier">Static</span> <span ><b>counter</b></span> <a href="#counter"><span class="icon ion-ios-link"></span></a> </span> </td> </tr> <tr> <td class="col-md-4"> <i>Type : </i> <code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/number" target="_blank" >number</a></code> </td> </tr> <tr> <td class="col-md-4"> <i>Default value : </i><code>0</code> </td> </tr> <tr> <td class="col-md-4"> <div class="io-line">Defined in <a href="" data-line="77" class="link-to-prism">src/tabs/tab.component.ts:77</a></div> </td> </tr> </tbody> </table> <table class="table table-sm table-bordered"> <tbody> <tr> <td class="col-md-4"> <a name="headingIsTemplate"></a> <span class="name"> <span class="modifier">Public</span> <span ><b>headingIsTemplate</b></span> <a href="#headingIsTemplate"><span class="icon ion-ios-link"></span></a> </span> </td> </tr> <tr> <td class="col-md-4"> <i>Default value : </i><code>false</code> </td> </tr> <tr> <td class="col-md-4"> <div class="io-line">Defined in <a href="" data-line="82" class="link-to-prism">src/tabs/tab.component.ts:82</a></div> </td> </tr> <tr> <td class="col-md-4"> <div class="io-description"><p>Boolean value reflects if the <code>Tab</code> is using a custom template for the heading. Default value is false.</p> </div> </td> </tr> </tbody> </table> </section> <section data-compodoc="block-accessors"> <h3 id="accessors"> Accessors </h3> <table class="table table-sm table-bordered"> <tbody> <tr> <td class="col-md-4"> <a name="cacheActive"></a> <span class="name"><b>cacheActive</b><a href="#cacheActive"><span class="icon ion-ios-link"></span></a></span> </td> </tr> <tr> <td class="col-md-4"> <span class="accessor"><b>get</b><code>cacheActive()</code></span> </td> </tr> <tr> <td class="col-md-4"> <div class="io-line">Defined in <a href="" data-line="133" class="link-to-prism">src/tabs/tab.component.ts:133</a></div> </td> </tr> <tr> <td class="col-md-4"> <span class="accessor"><b>set</b><code>cacheActive(shouldCache: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/boolean" target="_blank">boolean</a>)</code></span> </td> </tr> <tr> <td class="col-md-4"> <div class="io-line">Defined in <a href="" data-line="117" class="link-to-prism">src/tabs/tab.component.ts:117</a></div> </td> </tr> <tr> <td class="col-md-4"> <div class="io-description"><p>Set to true to have Tab items cached and not reloaded on tab switching.</p> </div> <div class="io-description"> <b>Parameters :</b> <table class="params"> <thead> <tr> <td>Name</td> <td>Type</td> <td>Optional</td> </tr> </thead> <tbody> <tr> <td>shouldCache</td> <td> <code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/boolean" target="_blank" >boolean</a></code> </td> <td> No </td> </tr> </tbody> </table> </div> <div> </div> <div class="io-description"> <b>Returns : </b> <code><a href="https://www.typescriptlang.org/docs/handbook/basic-types.html" target="_blank" >void</a></code> </div> </td> </tr> </tbody> </table> </section> </div> <div class="tab-pane fade tab-source-code" id="source"> <pre class="line-numbers compodoc-sourcecode"><code class="language-typescript">import { Component, OnInit, Input, Output, EventEmitter, TemplateRef, HostBinding } from &quot;@angular/core&quot;; /** * The &#x60;Tab&#x60; component is a child of the &#x60;Tabs&#x60; component. * It represents one &#x60;Tab&#x60; item and its content within a panel of other &#x60;Tab&#x60; items. * * * &#x60;Tab&#x60; takes a string or &#x60;TemplateRef&#x60; for the header, and any content for the body of the tab. * Disabled states should be handled by the application (ie. switch to the tab, but display some * indication as to _why_ the tab is disabled). * * When the tab is selected the &#x60;select&#x60; output will be triggered. * The &#x60;select&#x60; output will also be triggered for the active tab when the tabs are loaded or updated. * * * Tab with string header: * * &#x60;&#x60;&#x60;html * &lt;cds-tab heading&#x3D;&#x27;tab1&#x27;&gt; * tab 1 content * &lt;/cds-tab&gt; * &#x60;&#x60;&#x60; * * Tab with custom header: * * &#x60;&#x60;&#x60;html * &lt;ng-template #tabHeading&gt; * &lt;svg cdsIcon&#x3D;&quot;facebook&quot; * size&#x3D;&quot;sm&quot; * style&#x3D;&quot;margin-right: 7px;&quot;&gt; * &lt;/svg&gt; * Hello Tab 1 * &lt;/ng-template&gt; * &lt;cds-tabs&gt; * &lt;cds-tab [heading]&#x3D;&quot;tabHeading&quot;&gt; * Tab 1 content &lt;svg cdsIcon&#x3D;&quot;alert&quot; size&#x3D;&quot;lg&quot;&gt;&lt;/svg&gt; * &lt;/cds-tab&gt; * &lt;cds-tab heading&#x3D;&#x27;Tab2&#x27;&gt; * Tab 2 content * &lt;/cds-tab&gt; * &lt;cds-tab heading&#x3D;&#x27;Tab3&#x27;&gt; * Tab 3 content * &lt;/cds-tab&gt; * &lt;/cds-tabs&gt; * &#x60;&#x60;&#x60; */ @Component({ selector: &quot;cds-tab, ibm-tab&quot;, template: &#x60; &lt;div [attr.tabindex]&#x3D;&quot;tabIndex&quot; role&#x3D;&quot;tabpanel&quot; *ngIf&#x3D;&quot;shouldRender()&quot; class&#x3D;&quot;cds--tab-content&quot; [id]&#x3D;&quot;id&quot; [ngStyle]&#x3D;&quot;{&#x27;display&#x27;: active ? null : &#x27;none&#x27;}&quot; [attr.aria-labelledby]&#x3D;&quot;id + &#x27;-header&#x27;&quot; aria-live&#x3D;&quot;polite&quot;&gt; &lt;ng-template *ngIf&#x3D;&quot;isTemplate(tabContent)&quot; [ngTemplateOutlet]&#x3D;&quot;tabContent&quot; [ngTemplateOutletContext]&#x3D;&quot;{ $implicit: templateContext }&quot;&gt; &lt;/ng-template&gt; &lt;ng-content&gt;&lt;/ng-content&gt; &lt;/div&gt; &#x60; }) export class Tab implements OnInit { private static counter &#x3D; 0; /** * Boolean value reflects if the &#x60;Tab&#x60; is using a custom template for the heading. * Default value is false. */ public headingIsTemplate &#x3D; false; /** * The &#x60;Tab&#x60;&#x27;s title to be displayed or custom temaplate for the &#x60;Tab&#x60; heading. */ @Input() heading: string | TemplateRef&lt;any&gt;; /** * Optional override for the &#x60;tabItem&#x27;s&#x60;&#x27;s title attribute which is set in &#x60;TabHeaders&#x60;. * &#x60;tabItem&#x60;&#x27;s title attribute is automatically set to &#x60;heading&#x60;. * * You might want to use this if you set &#x60;heading&#x60; to a &#x60;TemplateRef&#x60;. */ @Input() title: string; /** * Allows the user to pass data to the custom template for the &#x60;Tab&#x60; heading. */ @Input() context: any; /** * Indicates whether the &#x60;Tab&#x60; is active/selected. * Determines whether it&#x27;s &#x60;TabPanel&#x60; is rendered. */ @Input() active &#x3D; false; /** * Indicates whether or not the &#x60;Tab&#x60; item is disabled. */ @Input() disabled &#x3D; false; @Input() tabIndex &#x3D; 0; /** * Sets the id of the &#x60;Tab&#x60;. Will be uniquely generated if not provided. */ @Input() id &#x3D; &#x60;n-tab-${Tab.counter++}&#x60;; /** * Set to true to have Tab items cached and not reloaded on tab switching. */ @Input() set cacheActive(shouldCache: boolean) { this._cacheActive &#x3D; shouldCache; } /** * Allows life cycle hooks to be called on the rendered content */ @Input() tabContent: TemplateRef&lt;any&gt;; /** * Optional data for templates passed as implicit context */ @Input() templateContext: any; /** * Value &#x27;selected&#x27; to be emitted after a new &#x60;Tab&#x60; is selected. */ @Output() selected: EventEmitter&lt;void&gt; &#x3D; new EventEmitter&lt;void&gt;(); get cacheActive() { return this._cacheActive; } protected _cacheActive &#x3D; false; /** * Checks for custom heading template on initialization and updates the value * of the boolean &#x27;headingIsTemplate&#x27;. */ ngOnInit() { if (this.heading instanceof TemplateRef) { this.headingIsTemplate &#x3D; true; } } /** * Emit the status of the &#x60;Tab&#x60;, specifically &#x27;select&#x27; and &#x27;selected&#x27; properties. */ doSelect() { this.selected.emit(); } /** * Returns value indicating whether this &#x60;Tab&#x60; should be rendered in a &#x60;TabPanel&#x60;. */ shouldRender() { return this.active || this.cacheActive; } public isTemplate(value) { return value instanceof TemplateRef; } } </code></pre> </div> <div class="tab-pane fade " id="tree"> <div id="tree-container"></div> <div class="tree-legend"> <div class="title"> <b>Legend</b> </div> <div> <div class="color htmlelement"></div><span>Html element</span> </div> <div> <div class="color component"></div><span>Component</span> </div> <div> <div class="color directive"></div><span>Html element with directive</span> </div> </div> </div> </div> <script src="../js/libs/vis.min.js"></script> <script src="../js/libs/htmlparser.js"></script> <script src="../js/libs/deep-iterator.js"></script> <script> var COMPONENT_TEMPLATE = '<div><div [attr.tabindex]="tabIndex" role="tabpanel" *ngIf="shouldRender()" class="cds--tab-content" [id]="id" [ngStyle]="{\'display\': active ? null : \'none\'}" [attr.aria-labelledby]="id + \'-header\'" aria-live="polite"> <ng-template *ngIf="isTemplate(tabContent)" [ngTemplateOutlet]="tabContent" [ngTemplateOutletContext]="{ $implicit: templateContext }"> </ng-template> <ng-content></ng-content></div> </div>' var COMPONENTS = [{'name': 'Accordion', 'selector': 'cds-accordion, ibm-accordion'},{'name': 'AccordionItem', 'selector': 'cds-accordion-item, ibm-accordion-item'},{'name': 'ActionableNotification', 'selector': 'cds-actionable-notification, ibm-actionable-notification'},{'name': 'AlertModal', 'selector': 'cds-alert-modal, ibm-alert-modal'},{'name': 'BaseIconButton', 'selector': ''},{'name': 'BaseNotification', 'selector': ''},{'name': 'BaseTabHeader', 'selector': ''},{'name': 'Breadcrumb', 'selector': 'cds-breadcrumb, ibm-breadcrumb'},{'name': 'BreadcrumbItemComponent', 'selector': 'cds-breadcrumb-item, ibm-breadcrumb-item'},{'name': 'ButtonSet', 'selector': 'cds-button-set, ibm-button-set'},{'name': 'Checkbox', 'selector': 'cds-checkbox, ibm-checkbox'},{'name': 'ClickableTile', 'selector': 'cds-clickable-tile, ibm-clickable-tile'},{'name': 'CodeSnippet', 'selector': 'cds-code-snippet, ibm-code-snippet'},{'name': 'ComboBox', 'selector': 'cds-combo-box, ibm-combo-box'},{'name': 'ComboButtonComponent', 'selector': 'cds-combo-button'},{'name': 'ContainedList', 'selector': 'cds-contained-list, ibm-contained-list'},{'name': 'ContainedListItem', 'selector': 'cds-contained-list-item, ibm-contained-list-item'},{'name': 'ContentSwitcher', 'selector': 'cds-content-switcher, ibm-content-switcher'},{'name': 'ContextMenuComponent', 'selector': 'cds-menu, cds-context-menu, ibm-context-menu'},{'name': 'ContextMenuDividerComponent', 'selector': 'cds-menu-divider, cds-context-menu-divider, ibm-context-menu-divider'},{'name': 'ContextMenuGroupComponent', 'selector': 'cds-menu-group, cds-context-menu-group, ibm-context-menu-group'},{'name': 'ContextMenuItemComponent', 'selector': 'cds-menu-item, cds-context-menu-item, ibm-context-menu-item'},{'name': 'DatePicker', 'selector': 'cds-date-picker, ibm-date-picker'},{'name': 'DatePickerInput', 'selector': 'cds-date-picker-input, ibm-date-picker-input'},{'name': 'Dialog', 'selector': 'cds-dialog, ibm-dialog'},{'name': 'Documentation', 'selector': 'cds-documentation'},{'name': 'Dropdown', 'selector': 'cds-dropdown, ibm-dropdown'},{'name': 'DropdownList', 'selector': 'cds-dropdown-list, ibm-dropdown-list'},{'name': 'ExpandableTile', 'selector': 'cds-expandable-tile, ibm-expandable-tile'},{'name': 'FileComponent', 'selector': 'cds-file, ibm-file'},{'name': 'FileUploader', 'selector': 'cds-file-uploader, ibm-file-uploader'},{'name': 'Hamburger', 'selector': 'cds-hamburger, ibm-hamburger'},{'name': 'Header', 'selector': 'cds-header, ibm-header'},{'name': 'HeaderAction', 'selector': 'cds-header-action, ibm-header-action'},{'name': 'HeaderGlobal', 'selector': 'cds-header-global, ibm-header-global'},{'name': 'HeaderItem', 'selector': 'cds-header-item, ibm-header-item'},{'name': 'HeaderMenu', 'selector': 'cds-header-men