Skip to content
This repository has been archived by the owner on Nov 20, 2018. It is now read-only.

Unable to import the module in Angular 2 #1839

Closed
chaitanyya opened this issue May 19, 2017 · 3 comments
Closed

Unable to import the module in Angular 2 #1839

chaitanyya opened this issue May 19, 2017 · 3 comments

Comments

@chaitanyya
Copy link

I tried importing the module in my angular 2 component using
import qq from 'fine-uploader';
and
import { qq } from 'fine-uploader';

It's giving me the following error:
/node_modules/fine-uploader/typescript/fine-uploader.d.ts is not a module.

I'm using version "5.14.2". I installed it using npm.

@chaitanyya
Copy link
Author

chaitanyya commented May 19, 2017

Okay, I finally figured it out. It'll be great if you add some similar process in your documentation. This is what I did to make it work:

Step Zero:
Include the CSS and JS file in the angular-cli.json file.

"styles": [
        "../node_modules/fine-uploader/fine-uploader/fine-uploader-gallery.min.css"
],
"scripts": [
        "../node_modules/fine-uploader/fine-uploader/fine-uploader.min.js"
],

Step One:
Add /// <reference types="fine-uploader" /> on top of your component file.

Step Two:
Declare following variables:

uploader: FineUploader.qq;
uiOptions: FineUploader.UIOptions;
coreEvents: FineUploader.CoreEvents;

Step Three:
Add UI options and initialise FineUploader in ngOnInit

this.uiOptions = {
    element: document.getElementById('qq-template'),
    template: "qq-template"
};
this.uploader = new qq.FineUploader(this.uiOptions);

Step Four:
Add the template HTML in your component.html file. You may find the HTML in node_modules/fine-uploader/fine-uploader/templates/

I can add more detailed process for TS integration in the Doc. But I want to confirm if it's the right way of doing it. @SinghSukhdeep

@singhjusraj
Copy link
Member

@chaitanyya yes this is the correct way of doing it as of now.
Have a look at here for more info on syntax.
Sorry about the documentation, whole TS integration details aren't documented properly.

@singhjusraj
Copy link
Member

This is fixed in #1840 and released in 5.15.0

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants