Skip to content

Instantly share code, notes, and snippets.

@yokoishioka
Last active March 4, 2020 06:49
Show Gist options
  • Save yokoishioka/4ec20e989d60feac6ea4c91c2b97b67c to your computer and use it in GitHub Desktop.
Save yokoishioka/4ec20e989d60feac6ea4c91c2b97b67c to your computer and use it in GitHub Desktop.
button that hides any parent
import { Component, Input, Renderer2, ElementRef, Output, EventEmitter } from '@angular/core';
@Component({
selector: 'ces-button-hide-parent',
templateUrl: './button-hide-parent.component.html',
styleUrls: ['./button-hide-parent.component.scss']
})
export class ButtonHideParentComponent {
@Input() showIcon: boolean;
@Input() label:string;
@Output() hidden: EventEmitter<any> = new EventEmitter();
constructor(
private renderer:Renderer2,
private elem:ElementRef
) { }
onClose() {
const parent = this.renderer.selectRootElement(this.elem.nativeElement.parentNode);
this.renderer.setStyle(parent, 'display', 'none')
this.hidden.emit();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment