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

Use this in AngularJS #19

Closed
Sadi-1992 opened this issue Mar 1, 2018 · 22 comments
Closed

Use this in AngularJS #19

Sadi-1992 opened this issue Mar 1, 2018 · 22 comments

Comments

@Sadi-1992
Copy link

I'm trying to use your library in my AngularJS project but i'm always getting the same Error:

Error: zipcelx is not defined

I cant use import zipcelx from 'zipcelx'; and have to install the lib using bower. ("zipcelx": "git://github.com/egeriis/zipcelx.git#1.2.0")

is there a way to "import" this into my project?

@egeriis
Copy link
Owner

egeriis commented Mar 1, 2018

Yes, that should definitely be possible. My theory is that bower doesn't look at the "main" configuration from package.json, since it's npm/yarn specific. But that would mean you'd have to import from the lib/zipcelx.js file.

@Sadi-1992
Copy link
Author

"that should definitely be possible" ... -____-

for your information: other plugins i've installed that way, are working well. i dont think that bower is the problem.

and i can't use "import" because its the wrong ES-Version.

Here my question in an other way: How can i "import" this into an AngularJs controller?

@egeriis
Copy link
Owner

egeriis commented Mar 2, 2018

No need to be snark.

and i can't use "import" because its the wrong ES-Version.

How do you import other modules?

@Sadi-1992
Copy link
Author

They are automatically imported by bower and usable out of the box without any "import-command". But unfortunately, that "auto-import" does not work with your plugin and it's not getting listed in the index.html as an imported script like others do.

@egeriis
Copy link
Owner

egeriis commented Mar 2, 2018

It's been a few years since I last looked at Bower, but looking at their docs it seems like you must have an additional build step. See "Use Packages" https://bower.io/#use-packages

@Sadi-1992
Copy link
Author

yes, that the way the bower-components get automatically imported:
<script src="bower_components/jquery/dist/jquery.min.js"></script>

i've added "zipcelx": "git://github.com/egeriis/zipcelx.git#1.2.0" into my bower.json but it doesn't work. Other Plugins installed that way are working well.

@egeriis
Copy link
Owner

egeriis commented Mar 2, 2018

This snippet doesn't import anything else than jQuery: <script src="bower_components/jquery/dist/jquery.min.js"></script>

You would need to add something like this: <script src="bower_components/zipcelx/lib/zipcelx.js"></script>

Verify the correct path by looking in your bower_components folder.

@Sadi-1992
Copy link
Author

... i know ... it's just the example from bower.io
and <script src="bower_components/zipcelx/lib/zipcelx.js"></script> should be added automatically by "gulp" if everything is alright..

@egeriis
Copy link
Owner

egeriis commented Mar 2, 2018

It may be that Bower doesn't know which file to use, because we don't have a Bower configuration in zipcelx. I'd err on the side of not adding that config, since Bower is practically deprecated. That doesn't mean you cannot use zipcelx, but you have to figure out how to get it into your build pipeline. As much as I'd like to help, I cannot because I don't have the information about your build pipeline that's necessary to help.

If you're using gulp, as you're indicating, you can add it to your build steps in your gulp configuration.

@PixelCrux
Copy link

Do you have a built version of the script anywhere? lib/zipxelx.js imports several dependencies, so it cannot be simply imported into HTML like you say.

@egeriis
Copy link
Owner

egeriis commented Mar 4, 2018

Good point @PixelCrux. We don’t, but I’ll fix that tomorrow.

@egeriis
Copy link
Owner

egeriis commented Mar 7, 2018

@PixelCrux @Sadi-1992 Forgot to mention here, but there's a standalone.js file in #20. Pending review, but you can download and test it. Let me know if it works for you too 🙂

@PixelCrux
Copy link

The script seems to have a bug. I tested in this Codepen: https://codepen.io/KingDragonhoff/pen/ddEXrv

@egeriis
Copy link
Owner

egeriis commented Mar 8, 2018

@PixelCrux That's not a very good bug description. In the future it'd be helpful to provide more info. With this regard I simply took at look at the console after clicking Download XLSX button. Give that a try yourself.

@PixelCrux
Copy link

PixelCrux commented Mar 8, 2018

Sorry, I figured you would be able to go to the Codepen and check your browser's console to see for yourself what error was occurring, but I'll try my best to describe it for you anyway. Visibly, nothing happens. When attempting to convert, the following exception occurs at line 1, column 151472: Uncaught TypeError: Cannot create property 'type' on number '1'. It points to this in the code:
e.type="string"

@egeriis
Copy link
Owner

egeriis commented Mar 8, 2018

I got an error from our lib in the console, because your data is invalid

@PixelCrux
Copy link

Ah, I see. It looks to be working now. Thank you for this!

@egeriis
Copy link
Owner

egeriis commented Mar 8, 2018

Thank you. Especially for continuing to be active. Your issue helped me make a better build pipeline and support more use cases ❤️

@PixelCrux
Copy link

You're welcome! Now, do you think it would be possible to make this work on iOS? Right now, it almost works, but the Blob it gives the option to download is just the plain Zip file, "unknown.zip." Any ideas how to tell Safari that this is an XLSX file?

@egeriis
Copy link
Owner

egeriis commented Mar 8, 2018

Hmm. That's an interesting question. iOS is a big peculiar with regards to file handling. Did you provide a filename, and it works properly on desktop?

@PixelCrux
Copy link

Yes, it works brilliantly on desktop and uses the file name I specify.

@egeriis
Copy link
Owner

egeriis commented Mar 9, 2018

Let's move converstation to #22

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

No branches or pull requests

3 participants