UNPKG

ng-ytl-zorro-antd

Version:

An enterprise-class UI components based on Ant Design and Angular

55 lines (50 loc) 1.57 kB
// tslint:disable import { Component } from '@angular/core'; import { NzMessageService } from './../../components/message/nz-message.service'; import { UploadFile } from './../../components/upload/interface'; @Component({ selector: 'nz-demo-upload-picture-card', template: ` <div class="clearfix"> <nz-upload nzAction="https://jsonplaceholder.typicode.com/posts/" nzListType="picture-card" [(nzFileList)]="fileList" [nzShowButton]="fileList.length < 3" [nzPreview]="handlePreview"> <i class="anticon anticon-plus"></i> <div class="ant-upload-text">Upload</div> </nz-upload> <nz-modal [nzVisible]="previewVisible" [nzContent]="modalContent" [nzFooter]="null" (nzOnCancel)="previewVisible=false"> <ng-template #modalContent> <img [src]="previewImage" [ngStyle]="{ 'width': '100%' }" /> </ng-template> </nz-modal> </div> `, styles: [` :host ::ng-deep i { font-size: 32px; color: #999; } :host ::ng-deep .ant-upload-text { margin-top: 8px; color: #666; } `] }) export class NzDemoUploadPictureCardComponent { fileList = [{ uid: -1, name: 'xxx.png', status: 'done', url: 'https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png', }]; previewImage = ''; previewVisible = false; constructor(private msg: NzMessageService) {} handlePreview = (file: UploadFile) => { this.previewImage = file.url || file.thumbUrl; this.previewVisible = true; } }