沈斌
2017-12-15 f9b157566af34b8dc28ba10b34d025ac04f3168b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import { Component, ElementRef, Inject, OnInit } from '@angular/core';
import { DOCUMENT } from '@angular/common';
import { NzMessageService } from 'ng-zorro-antd';
import { _HttpClient } from '@delon/theme';
 
@Component({
    selector: 'app-iconsfont',
    templateUrl: './iconsfont.component.html'
})
export class IconsFontComponent implements OnInit {
    data = [];
 
    constructor(
        private msg: NzMessageService,
        private http: _HttpClient,
        @Inject(DOCUMENT) private dom: Document, private _el: ElementRef) { }
 
    ngOnInit(): void {
        this.http.get('./assets/iconsfont.json').subscribe(res => this.data = res);
    }
 
    copy(group: any, item: any) {
        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);
            }
        }
    }
}