pIvan / file-upload

drag and drop file component
MIT License
87 stars 12 forks source link

Unknown error with Angular v8 #56

Closed amit-mixturebox closed 3 years ago

amit-mixturebox commented 3 years ago

ERROR in node_modules/@iplab/ngx-file-upload/lib/components/attribute/file-upload-attr.component.d.ts(18,9): error TS1086: An accessor cannot be declared in an ambient context. node_modules/@iplab/ngx-file-upload/lib/components/attribute/file-upload-attr.component.d.ts(19,9): error TS1086: An accessor cannot be declared in an ambient context. node_modules/@iplab/ngx-file-upload/lib/components/multiple-file-upload/file-upload.component.d.ts(14,9): error TS1086: An accessor cannot be declared in an ambient context.

pIvan commented 3 years ago

Hi @amit-mixturebox, can you tell me which version of ngx-file-upload did you used? Thanks

amit-mixturebox commented 3 years ago

Thanks plvan for quick reply. First of all Kudos to the great work done by you - I m very much impressed with the stuffs you have done - and would like to integrate within my application

While integrating within application I am facing some issues which is listed as below -

Compatible with Angular V8 is resolved now -

I have installed "@iplab/ngx-file-upload": "1.5.4", - now I m not getting issue after npm install -

But there is some confusion around validation and customization of the UI -

Here is my code -

*.component.ts

import {FileUploadControl, FileUploadValidators} from '@iplab/ngx-file-upload';

public uploadedFile: File[] = [];

I tried both way - but neither works !!!!

*.component.html

<file-upload [(ngModel)]="uploadedFile" (change)="checkfileformat()" [accept]="audio/mp3" [multiple]="false" name="uploadedFile" [control]="fileUploadControl">

Option - 1

public fileUploadControl = new FileUploadControl(null, FileUploadValidators.accept(['audio/*']));

Option-2

[> public fileUploadControl = new FileUploadControl(

// control configuration
{listVisible: false, discardInvalid: true, accept: ['audio/*']},

// validator used to discard files
[FileUploadValidators.accept(['audio/*']), FileUploadValidators.fileSize(80000)]

);](url)

I am getting the below error in console -

ERROR Error: Uncaught (in promise): TypeError: validator is not a function TypeError: validator is not a function at iplab-ngx-file-upload.js:364 at Array.map () at FileUploadControl.validate (iplab-ngx-file-upload.js:360) at FileUploadControl.addMultipleFiles (iplab-ngx-file-upload.js:167) at FileUploadControl.setValue (iplab-ngx-file-upload.js:211) at FileUploadComponent.writeValue (iplab-ngx-file-upload.js:1843)

Please assist @pIvan image-1

And how to customise the css of existing elements.

Than

pIvan commented 3 years ago

Hi @amit-mixturebox, the older version does not have configuration over constructor, also if you use [control] property, you do not need to use [ngModel] and all other

*.component.html <file-upload name="uploadedFile" [control]="fileUploadControl">

*.component.ts

import {FileUploadControl, FileUploadValidators} from '@iplab/ngx-file-upload';

// there is only one argument
public fileUploadControl: FileUploadControl = new FileUploadControl(FileUploadValidators.accept(['audio/*']));

or you can add multiple validations

public fileUploadControl: FileUploadControl = new FileUploadControl(
  [FileUploadValidators.accept(['audio/*']), FileUploadValidators.fileSize(80000)]
);

as far as CSS is concerned, currently, it is encapsulated, so if you want to change CSS the best way is to add a custom template or to use !important rule

pIvan commented 3 years ago

closing due to inactivity