ng-semantic
Version:
Angular2 building blocks based on Semantic UI
56 lines (46 loc) • 1.55 kB
text/typescript
import {
Component, QueryList, AfterViewInit, ElementRef, Input, Type, ContentChildren, ViewChild
} from "@angular/core";
declare var jQuery: any;
export class SemanticTabComponent implements AfterViewInit {
tab: number;
title: string;
active: boolean;
tabEl: ElementRef;
ngAfterViewInit() {
this.tabEl.nativeElement.parentElement.classList.add("ui", "tab", "bottom", "attached", "segment");
if (this.active) {
this.tabEl.nativeElement.parentElement.classList.add("active");
}
}
}
export class SemanticTabsComponent implements AfterViewInit {
tabs: QueryList<SemanticTabComponent>;
menu: ElementRef;
constructor(public elementRef: ElementRef) {}
ngAfterViewInit() {
this.tabs
.map((cmp: SemanticTabComponent, index: number) => {
cmp.tabEl.nativeElement.parentElement.setAttribute("data-tab", index.toString());
});
jQuery(this.menu.nativeElement.getElementsByClassName("item")).tab({
childrenOnly: true,
context: jQuery(this.elementRef.nativeElement)
});
}
}