danialfarid / ng-file-upload

Lightweight Angular directive to upload files with optional FileAPI shim for cross browser support
MIT License
7.87k stars 1.59k forks source link

TypeScript example #1553

Open eestein opened 8 years ago

eestein commented 8 years ago

Hi, I couldn't find an example using TS. Is there any? I've already installed the typings typings install dt~ng-file-upload --save --global -SG but I can't find the example on how it's used.

Any ideas?

Thanks!

apiweb commented 8 years ago

Please, add a Typescript example to use ng-file-upload. It is almost impossible to find examples using ng-file-upload with typescript, an example would be very welcome.

andersnorgaard commented 8 years ago

What kinds of examples are you looking for @eestein and @apiweb ? I use the examples with Typescript with minimal changes.

eestein commented 8 years ago

@andersnorgaard basic examples like a "Getting Started" tutorial. I wasn't able to get the lib to work using TS so an example would tell me what am I doing wrong.

andersnorgaard commented 8 years ago

@eestein But do you already have a working Typescript + AngularJS setup? I did, and adding this module was painless.

stombeur commented 8 years ago

When using this in typescript, if you inject the upload service as a typed variable, e.g. private Upload: angular.angularFileUpload.IUploadService,

then the config object needs to be typed as angular.angularFileUpload.IFileUploadConfigFile and that does not have a file property.

Injecting the service as any and then just using the examples in JS works, but for me it's not clear how we can do this in a properly typed way.

andersnorgaard commented 8 years ago

@stombeur Yes. I just use the upload service as "any" also.

arlevitt commented 7 years ago

I agree... would it be possible to see an actual example of a typescript controller having this service injected into it? Even injecting the service as "any" seems to fail the provider.

danialfarid commented 7 years ago

For version 2 all the code is in TypeScript and I will eventually port it back to Angular 1 to be able to use the same code base. So there is the plan to have the code in TypeScript.

ravishan110 commented 7 years ago

@andersnorgaard can you show how you used it in typescript. It will be very helpful for me and many others like me.

jespinosa94 commented 7 years ago

I am also trying to implement the lib in a running TypeScript project and it's very difficult with no examples, it would be nice if somebody already implemented it and could share how to do it.

andyrus commented 6 years ago

Hi I am using angular 1.5 and typescript, is there an example anywhere on how this is implemented using typescript yet? Many Thanks