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

fix(tabs): fix customClass for tab content #2883

Merged
merged 1 commit into from
Oct 20, 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/ng-api-doc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2449,7 +2449,7 @@ export const ngdoc: any = {
{
"name": "customClass",
"type": "string",
"description": "<p>if set, will be added to the tab&#39;s class atribute. Multiple classes are supported. </p>\n"
"description": "<p>if set, will be added to the tab&#39;s class attribute. Multiple classes are supported. </p>\n"
},
{
"name": "disabled",
Expand Down
20 changes: 16 additions & 4 deletions src/tabs/tab.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,34 @@ import { TabsetComponent } from './tabset.component';
@Directive({ selector: 'tab, [tab]' })
export class TabDirective implements OnInit, OnDestroy {
/** tab header text */
@Input() public heading: string;
@Input() 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;
@Input() id: string;
/** if true tab can not be activated */
@Input() disabled: boolean;
/** if true tab can be removable, additional button will appear */
@Input() removable: boolean;
/** if set, will be added to the tab's class atribute. Multiple classes are supported. */
/** if set, will be added to the tab's class attribute. Multiple classes are supported. */
@Input()
get customClass(): string {
return this._customClass;
}

set customClass(customClass: string) {
this._customClass = customClass;
if (this.customClass) {
this.customClass.split(' ').forEach((cssClass: string) => {
this.renderer.removeClass(this.elementRef.nativeElement, cssClass);
});
}

this._customClass = customClass ? customClass.trim() : null;

if (this.customClass) {
this.customClass.split(' ').forEach((cssClass: string) => {
this.renderer.addClass(this.elementRef.nativeElement, cssClass);
});
}
}

/** tab active state toggle */
Expand Down