UNPKG

ngx-pluto

Version:
53 lines (52 loc) 2.08 kB
import { OnInit, EventEmitter } from "@angular/core"; import { DomSanitizer } from "@angular/platform-browser"; import { ControlValueAccessor, Validator, AbstractControl, ValidationErrors } from "@angular/forms"; /** * 图片上传组件 - 支持NgModel和reactive forms * * <example-url>https://stackblitz.com/edit/np-img-upload-sample?embed=1&file=src/app/app.component.html</example-url> */ export declare class NpImgUpload implements OnInit, ControlValueAccessor, Validator { private sanitizer; private emitChange; /**标签 */ label: string; /**是否禁用 */ isDisabled: boolean; /**是否忽略宽高检查,true - 忽略宽高检查,false - 检查宽高 */ ignoreWidthAndHeightCheck: boolean; /**是否必填 - 必填则有红色*号在标签前面;否则没有 */ isRequired: boolean; /**上传图片按钮文字 */ btnText: string; /**图片描述,如尺寸、格式、大小等 */ imgDesc: string; /**图片格式,默认jpg、png和jpeg */ imgFormat: string; /**图片大小,默认最大500kb */ maxSize: number; /**图片宽度px */ width: number; /**图片高度px */ height: number; /**错误信息 - 将以红色字体显示在上传按钮下方 */ errorMessage: string; /**当重新选择图片时触发 */ onImgFileChanged: EventEmitter<any>; /**上传错误,如尺寸不对、格式不对,大小不对等 */ onUploadError: EventEmitter<string>; /**点击缩略图是触发 */ onImgClicked: EventEmitter<any>; currentImgFile: File; currentImgSrc: any; constructor(sanitizer: DomSanitizer); ngOnInit(): void; onCurrentImgFileChanged(file: File): void; onUploadImgFormatError(msg: string): void; onCurrentImgClick(): void; writeValue(obj: any): void; validate(control: AbstractControl): ValidationErrors; registerOnChange(fn: any): void; registerOnTouched(fn: any): void; setDisabledState?(isDisabled: boolean): void; }