import { Component , ElementRef , Inject , OnInit } from '@angular/core' ; import { DOCUMENT } from '@angular/common' ; import { NzMessageService } from 'ng-zorro-antd' ; import { HttpClient , HttpErrorResponse } from '@angular/common/http' ; @ Component ( { selector : 'app-iconsfont' , templateUrl : './iconsfont.component.html' } ) export class IconsFontComponent implements OnInit { data = [ ] ; constructor ( private msg , private httpClient , @ Inject ( DOCUMENT ) private dom , private _el ) { } ngOnInit ( ) { this . httpClient . get ( '/assets/iconsfont.json' ) . subscribe ( ( res ) => this . data = res ) ; } copy ( group , item ) { let copyTextArea = null as HTMLTextAreaElement ; try { copyTextArea = this . dom . createElement ( 'textarea' ) ; copyTextArea . style . height = '0px' ; copyTextArea . style . opacity = '0' ; copyTextArea . style . width = '0px' ; this . dom . body . appendChild ( copyTextArea ) ; copyTextArea . value = group . tpl . replace ( `{0}` , item . k ) ; copyTextArea . select ( ) ; this . dom . execCommand ( 'copy' ) ; this . msg . success ( `Copied Success!` ) ; } finally { if ( copyTextArea && copyTextArea . parentNode ) { copyTextArea . parentNode . removeChild ( copyTextArea ) ; } } } }