Last active
April 19, 2017 11:23
-
-
Save klinki/0b48d868a9d8897a237e290b678d1478 to your computer and use it in GitHub Desktop.
Expand/collapse component
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div> | |
<a [ngClass]="{'active': isActive}" (click)="toggle()">{{tabTitle}}</a> | |
<ng-content *ngIf="isActive"></ng-content> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {Component} from "@angular/core"; | |
import {TabComponent} from "./tab.component"; | |
/** | |
* Component for expand/collapse interface | |
* | |
* | |
* Usage: | |
* <wu-expand-collapse [tabTitle]="'Title'"> | |
* .... content here..... | |
* </wu-expand-collapse> | |
* | |
*/ | |
@Component({ | |
templateUrl: './expand-collapse.component.html', | |
selector: 'wu-expand-collapse', | |
styleUrls: ['./expand-collapse.component.scss'] | |
}) | |
export class ExpandCollapseComponent extends TabComponent { | |
/** | |
* Sets selected tab as active | |
*/ | |
toggle() { | |
this.isActive = !this.isActive; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment