zefoy / ngx-dropzone-wrapper

Angular wrapper library for Dropzone
MIT License
174 stars 51 forks source link

Action Delete Image #182

Open MahmoudCalipso opened 7 months ago

MahmoudCalipso commented 7 months ago

image i get issue about the button check and remove :when i need to remove the file the button doesn't work ngx-dropzone-wrapper 10.0.1 & Angular 9.0.2 `export class DocumentListComponent extends BaseFormComponent implements OnInit { @ViewChild(DatatableComponent, { static: false }) table: DatatableComponent; @ViewChild('dz', { static: false}) drpzone: DropzoneComponent; @ViewChild(DropzoneDirective, { static: false }) directiveRef?: DropzoneDirective; singleConfig: DropzoneConfigInterface = { ...defaultConfig, ...{ maxFiles: 1, cancelReset: 1, errorReset: 1 } }; ..... onUploadInit(args: any): void { }

onUploadError(args: any): void { this.toastrService.error( 'Error.', 'The file is too large ( Max Size 10 MB )', { progressBar: true } );

const previewElement = args.previewElement;
if (previewElement) {
  // Remove the preview element from the DOM
  previewElement.parentNode.removeChild(previewElement);
}

this.uploaded = false;

}

onRemove(args: any) { console.log(args); if (this.drpzone && this.drpzone.directiveRef) { this.file = null; this.drpzone.directiveRef.reset(true); } }

onUploadSuccess(args: any): void { this.file = args[0]; this.pdfurl = args[1].documentUrl; this.uploaded = false; this.toastrService.success('Success.', 'Successfully uploaded PDF', { progressBar: true }); }

onSending(args: any): void { const file = args[0]; this.uploaded = true } **and this DocumentsModule** const DEFAULT_DROPZONE_CONFIG: DropzoneConfigInterface = { url: ${environment.serverUrl}/mediamgt/api/Media/UploadDocument/FormFile, maxFilesize: 10, acceptedFiles: 'application/pdf' };

@NgModule({ declarations: [DocumentDetailsComponent, DocumentListComponent], imports: [ CommonModule, ModalModule.forRoot(), OnlynumberDirectiveModule, FormControlsModule, SharedModule, CardsModule, UtilsModule, NgxDatatableModule, IconsModule, NgSelectModule, ProgressModule, TrainerRoutingModule, DropzoneModule ], providers: [ DocumentService, UploadImageService, HttpClient, { provide: HTTP_INTERCEPTORS, useClass: AuthHttpInterceptor, multi: true }, { provide: DROPZONE_CONFIG, useValue: DEFAULT_DROPZONE_CONFIG } ], exports: [DocumentListComponent, DocumentDetailsComponent] }) export class DocumentsModule {} **the html code :**

Drop files here or Click to upload.

                  </div>`