Skip to content

Commit 89defda

Browse files
IlyaSurmayvalorkin
authored andcommitted
feat(tab): add tab id support (#2405)
1 parent 8da0c94 commit 89defda

File tree

6 files changed

+9
-8
lines changed

6 files changed

+9
-8
lines changed

demo/src/app/components/+tabs/demos/basic/basic.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<div>
22
<tabset>
3-
<tab heading="Static title">Static content</tab>
3+
<tab heading="Static title" id="tab1">Static content</tab>
44
<tab heading="Static Title 1">Static content 1</tab>
55
<tab heading="Static Title 2">Static content 2</tab>
66
<tab (select)="alertMe()">

demo/src/app/components/+tabs/demos/basic/basic.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import { Component, ViewChild } from '@angular/core';
2-
import { TabsetComponent } from 'ngx-bootstrap';
1+
import { Component } from '@angular/core';
32

43
@Component({
54
selector: 'demo-tabs-basic',
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"version":"2.0.0-beta.5"}
1+
{"version":"2.0.0-beta.6"}

demo/src/ng-api-doc.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2464,7 +2464,7 @@ export const ngdoc: any = {
24642464
{
24652465
"name": "id",
24662466
"type": "string",
2467-
"description": "<p>tab id </p>\n"
2467+
"description": "<p>tab id. The same id with suffix &#39;-link&#39; will be added to the corresponding &lt;li&gt; element </p>\n"
24682468
},
24692469
{
24702470
"name": "removable",

src/tabs/tab.directive.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,10 @@ import { TabsetComponent } from './tabset.component';
1515
@Directive({ selector: 'tab, [tab]' })
1616
export class TabDirective implements OnInit, OnDestroy {
1717
/** tab header text */
18-
@Input() heading: string;
19-
/** tab id */
20-
@Input() id: string;
18+
@Input() public heading: string;
19+
/** tab id. The same id with suffix '-link' will be added to the corresponding &lt;li&gt; element */
20+
@HostBinding('attr.id')
21+
@Input() public id: string;
2122
/** if true tab can not be activated */
2223
@Input() disabled: boolean;
2324
/** if true tab can be removable, additional button will appear */

src/tabs/tabset.component.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
<li *ngFor="let tabz of tabs" [ngClass]="['nav-item', tabz.customClass || '']"
33
[class.active]="tabz.active" [class.disabled]="tabz.disabled">
44
<a href="javascript:void(0);" class="nav-link"
5+
[attr.id]="tabz.id ? tabz.id + '-link' : ''"
56
[class.active]="tabz.active" [class.disabled]="tabz.disabled"
67
(click)="tabz.active = true">
78
<span [ngTransclude]="tabz.headingRef">{{ tabz.heading }}</span>

0 commit comments

Comments
 (0)