import { Component , EventEmitter , Input , OnInit , Output } from '@angular/core' ; @ Component ( { selector : 'alert' , templateUrl : './alert.component.html' } ) export class AlertComponent implements OnInit { @ Input ( ) public type : string = 'warning' ; @ Input ( ) public dismissible : boolean ; @ Input ( ) public dismissOnTimeout : number ; @ Output ( ) public close : EventEmitter < AlertComponent > = new EventEmitter < AlertComponent > ( false ) ; public closed : boolean ; protected classes : Array < string > = [ ] ; public ngOnInit ( ) { this . classes [ 0 ] = `alert-${ this . type }` ; if ( this . dismissible ) { this . classes [ 1 ] = 'alert-dismissible' ; } else { this . classes . length = 1 ; } if ( this . dismissOnTimeout ) { setTimeout ( ( ) => this . onClose ( ) , this . dismissOnTimeout ) ; } } public onClose ( ) { this . closed = true ; this . close . emit ( this ) ; } }