Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does this package work in Angular 7? #160

Closed
nithincn89 opened this issue Sep 20, 2019 · 5 comments
Closed

Does this package work in Angular 7? #160

nithincn89 opened this issue Sep 20, 2019 · 5 comments

Comments

@nithincn89
Copy link

I have my application in Angular 7. After installing this package and importing it to the application, it is not working properly.

When I am using the following command 'var color = Color('rgb(255, 255, 255)')' , I am getting following error in the console.

ERROR TypeError: Object(...) is not a function

Can anyone check this and help to solve the issue?

@dlasagno
Copy link

I used this package with typescript and it was working, can you provide the import line? Maybe it is the problem.

@nithincn89
Copy link
Author

Thanks for your reply. I used the following method to import it.

import { Color } from 'color';

Is it causes the problem? Then please guide me with the right way.

@dlasagno
Copy link

Yes, it is the problem.
This is the right way of importing the package:

import * as Color from 'color'

The problem is that the syntax that you used works only if the package 'color' exports an object with an entry named Color. But since 'color' exports a function typescript(or javascript) can't apply an object destructuring to it.
By using the above syntax you just take whatever 'color' exports and you name it 'Color'.

If you want to find out more on the subject I suggest you to read this: https://medium.com/backticks-tildes/introduction-to-es6-modules-49956f580da

@nithincn89
Copy link
Author

@dlasagno That's work great. Thanks for your guidance and solution.

@Qix-
Copy link
Owner

Qix- commented Sep 20, 2019

Glad you got it figured out.

@Qix- Qix- closed this as completed Sep 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants