Skip to content

Instantly share code, notes, and snippets.

@klinki
Last active April 19, 2017 11:23
Show Gist options
  • Save klinki/0b48d868a9d8897a237e290b678d1478 to your computer and use it in GitHub Desktop.
Save klinki/0b48d868a9d8897a237e290b678d1478 to your computer and use it in GitHub Desktop.
Expand/collapse component
<div>
<a [ngClass]="{'active': isActive}" (click)="toggle()">{{tabTitle}}</a>
<ng-content *ngIf="isActive"></ng-content>
</div>
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