import { Component , HostListener , Input , OnInit } from '@angular/core' ; import { CopierService } from '../copier/copier.service' ; @ Component ( { selector : 'dg-copy,[dgCopy]' , templateUrl : './copy.component.html' , host : { class : 'dg-copy' } } ) export class CopyComponent implements OnInit { public icon = 'copy' ; @ Input ( ) text : string ; @ Input ( 'dgCopy' ) set dgCopy ( text ) { this . text = text ; } constructor ( private copier ) { } ngOnInit ( ) { } @ HostListener ( 'click' , [ '$event' ] ) copy ( $event ) { this . copier . copyText ( this . text ) ; this . icon = 'check' ; setTimeout ( ( ) => { this . icon = 'copy' ; } , 2000 ) ; } }