NetanelBasal
7/23/2018 - 2:45 PM

snackbar-2.ts

@Component({
  template: `
   <div class="snackbar-container">
     {{ content }} <button (click)="close()">&#x2715;</button>
   </div>
  `
})
export class SnackbarComponent {
  @Input() content = '';
  @Output() afterClose = new EventEmitter();

  constructor(private host: ElementRef<HTMLElement>) { }

  get container(): HTMLElement {
    return this.host.nativeElement.querySelector('.snackbar-container') as HTMLElement;
  }

  close() {
    this.container.style.animation = 'snackbarOut 0.3s';
  }

}