Last active
August 4, 2017 21:06
-
-
Save karan-kang/5f0facd761b2bd6f760bda1ca9ba83c8 to your computer and use it in GitHub Desktop.
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, ElementRef, OnDestroy, OnInit, ViewEncapsulation } from '@angular/core'; | |
import { AppPanelService } from './appPanel.service'; | |
/** | |
* This component allows the user to toggle the app panel size between full screen and normal | |
* views. | |
*/ | |
@Component({ | |
selector: 'expand-panel', | |
template: ` | |
<a class="panel-expand" (click)="expand()"> | |
<i class="fa" [ngClass]="{ 'fa-expand': !expanded, 'fa-compress': expanded }"></i> | |
</a> | |
`, | |
encapsulation: ViewEncapsulation.None, | |
viewProviders: [ | |
AppPanelService | |
] | |
}) | |
export class ExpandPanelComponent implements OnInit, OnDestroy { | |
private panel: Element; | |
public expanded = false; | |
constructor(private element: ElementRef, private appPanelService: AppPanelService) { | |
} | |
/** | |
* Initialize this component | |
*/ | |
public ngOnInit() { | |
this.panel = this.appPanelService.getPanelElement(this.element.nativeElement); | |
} | |
/** | |
* Destroy this component | |
*/ | |
public ngOnDestroy() { | |
this.panel = undefined; | |
} | |
public expand() { | |
this.expanded = this.appPanelService.expandPanel(this.panel); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment