Skip to content

Instantly share code, notes, and snippets.

@pankajparkar
Last active April 1, 2019 04:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pankajparkar/f7059c6b3f680bf0eae39fbdc06e01ec to your computer and use it in GitHub Desktop.
Save pankajparkar/f7059c6b3f680bf0eae39fbdc06e01ec to your computer and use it in GitHub Desktop.
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'tabs',
template: `
<div class="tabbable">
<ul class="nav nav-tabs">
<li *ngFor="let pane of panes" [ngClass]="{active:pane.selected}">
<a href="#" (click)="select(pane)">
{{pane.title}}
</a>
</li>
</ul>
<div class="tab-content">
<ng-content></ng-content>
</div>
</div>
`,
styleUrls: ['./tabs.component.css']
})
export class TabsComponent implements OnInit {
constructor() { }
panes = []
select(pane) {
this.panes.forEach((p) => {
p.selected = false;
});
pane.selected = true;
};
addPane(pane) {
if (this.panes.length === 0) {
this.select(pane);
}
this.panes.push(pane);
};
ngOnInit() {
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment