Cannot created public uploader #987

Open
opened 2018-03-12 18:01:50 +00:00 by smlombardi · 2 comments
smlombardi commented 2018-03-12 18:01:50 +00:00 (Migrated from github.com)

Following the docs, I get a typescript error of

Argument of type '{ url: { new (url: string, base?: string): URL; prototype: URL; createObjectURL(object: any, opti...' is not assignable to parameter of type 'FileUploaderOptions'.
  Types of property 'url' are incompatible.
    Type '{ new (url: string, base?: string): URL; prototype: URL; createObjectURL(object: any, options?: O...' is not assignable to type 'string'.

When using public uploader: FileUploader = new FileUploader({ url: URL });

System specs:

Angular CLI: 1.7.1
Node: 6.11.2
OS: darwin x64
Angular: 5.2.6
... animations, common, compiler, compiler-cli, core, forms
... http, platform-browser, platform-browser-dynamic
... platform-server, router

@angular/cli: 1.7.1
@angular-devkit/build-optimizer: 0.3.2
@angular-devkit/core: 0.4.2
@angular-devkit/schematics: 0.4.2
@ngtools/json-schema: 1.1.0
@ngtools/webpack: 1.10.1
@schematics/angular: 0.3.2
@schematics/package-update: 0.3.2
typescript: 2.6.2
webpack: 3.11.0
Following the docs, I get a typescript error of ``` Argument of type '{ url: { new (url: string, base?: string): URL; prototype: URL; createObjectURL(object: any, opti...' is not assignable to parameter of type 'FileUploaderOptions'. Types of property 'url' are incompatible. Type '{ new (url: string, base?: string): URL; prototype: URL; createObjectURL(object: any, options?: O...' is not assignable to type 'string'. ``` When using `public uploader: FileUploader = new FileUploader({ url: URL });` System specs: ``` Angular CLI: 1.7.1 Node: 6.11.2 OS: darwin x64 Angular: 5.2.6 ... animations, common, compiler, compiler-cli, core, forms ... http, platform-browser, platform-browser-dynamic ... platform-server, router @angular/cli: 1.7.1 @angular-devkit/build-optimizer: 0.3.2 @angular-devkit/core: 0.4.2 @angular-devkit/schematics: 0.4.2 @ngtools/json-schema: 1.1.0 @ngtools/webpack: 1.10.1 @schematics/angular: 0.3.2 @schematics/package-update: 0.3.2 typescript: 2.6.2 webpack: 3.11.0 ```
koenvanderlinden commented 2018-03-29 14:02:49 +00:00 (Migrated from github.com)

The problem is that the URL variable cannot be resolved.

You should do it like this:

private URL: string = '/someurl';
public uploader: FileUploader = new FileUploader({ url: this.URL });
The problem is that the URL variable cannot be resolved. You should do it like this: ``` private URL: string = '/someurl'; public uploader: FileUploader = new FileUploader({ url: this.URL }); ```
rahulgiri commented 2018-05-04 06:37:16 +00:00 (Migrated from github.com)

The above solution fixed my problem. 👍

The above solution fixed my problem. 👍
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: dc/ng2-file-upload#987