import { NzTabChangeEvent } from 'ng-zorro-antd/src/tabs/nz-tabset.component'; import { Component, OnInit, OnDestroy, Input, Output } from '@angular/core'; import { DocContainerService } from './doc-container.service'; import { CmMessageService } from '../../../../../components/cosmos.module'; @Component({ selector: 'cm-doc-container', templateUrl: './doc-container.component.html', styleUrls: ['./doc-container.component.css'] }) export class DocContainerComponent implements OnInit, OnDestroy { _nzTabPosition: string = 'top'; _title: string = ""; _intro: string = ""; _htmlPath: string = ""; _tsPath: string = ""; _tabs = [ { name: '示例', key: 'demo', value: '' }, { name: 'html', key: 'html', value: 'html' }, { name: 'ts', key: 'ts', value: 'ts' } ]; constructor(private docService: DocContainerService, private messageService: CmMessageService) { } onCopy(status: boolean) { if (status) { this.messageService.success("复制成功"); } else { this.messageService.success("复制错误"); } } nzSelectChange(event: NzTabChangeEvent) { if (event.index == 1) { this.docService.getHtmlCode(this._htmlPath).then(data => { this._tabs[1].value = data; }); } else if (event.index == 2) { this.docService.getTsCode(this._tsPath).then(data => { this._tabs[2].value = data; }); } } @Input() set title(title: string) { this._title = title; } @Input() set intro(intro: string) { this._intro = intro; } @Input() set htmlPath(htmlPath: string) { this._htmlPath = htmlPath; } @Input() set tsPath(tsPath: string) { this._tsPath = tsPath; } ngOnInit() { } ngOnDestroy() { } }