Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(tab): add tab id support #2405

Merged
merged 2 commits into from
Oct 13, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion demo/src/app/components/+tabs/demos/basic/basic.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div>
<tabset>
<tab heading="Static title">Static content</tab>
<tab heading="Static title" id="tab1">Static content</tab>
<tab heading="Static Title 1">Static content 1</tab>
<tab heading="Static Title 2">Static content 2</tab>
<tab (select)="alertMe()">
Expand Down
3 changes: 1 addition & 2 deletions demo/src/app/components/+tabs/demos/basic/basic.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Component, ViewChild } from '@angular/core';
import { TabsetComponent } from 'ngx-bootstrap';
import { Component } from '@angular/core';

@Component({
selector: 'demo-tabs-basic',
Expand Down
2 changes: 1 addition & 1 deletion demo/src/assets/json/current-version.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"version":"2.0.0-beta.5"}
{"version":"2.0.0-beta.6"}
2 changes: 1 addition & 1 deletion demo/src/ng-api-doc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2464,7 +2464,7 @@ export const ngdoc: any = {
{
"name": "id",
"type": "string",
"description": "<p>tab id </p>\n"
"description": "<p>tab id. The same id with suffix &#39;-link&#39; will be added to the corresponding &lt;li&gt; element </p>\n"
},
{
"name": "removable",
Expand Down
7 changes: 4 additions & 3 deletions src/tabs/tab.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@ import { TabsetComponent } from './tabset.component';
@Directive({ selector: 'tab, [tab]' })
export class TabDirective implements OnInit, OnDestroy {
/** tab header text */
@Input() heading: string;
/** tab id */
@Input() id: string;
@Input() public heading: string;
/** tab id. The same id with suffix '-link' will be added to the corresponding &lt;li&gt; element */
@HostBinding('attr.id')
@Input() public id: string;
/** if true tab can not be activated */
@Input() disabled: boolean;
/** if true tab can be removable, additional button will appear */
Expand Down
1 change: 1 addition & 0 deletions src/tabs/tabset.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<li *ngFor="let tabz of tabs" [ngClass]="['nav-item', tabz.customClass || '']"
[class.active]="tabz.active" [class.disabled]="tabz.disabled">
<a href="javascript:void(0);" class="nav-link"
[attr.id]="tabz.id ? tabz.id + '-link' : ''"
[class.active]="tabz.active" [class.disabled]="tabz.disabled"
(click)="tabz.active = true">
<span [ngTransclude]="tabz.headingRef">{{ tabz.heading }}</span>
Expand Down