Hello All,
I´m a few days trying found the way how to get together Angular 5 with Muuri.
I have a simple working Angular5 project in the Visual Studio Code.
I installed murri+web-animation+hammerjs using npm and add the script into .angular-cli.json .
In tsconfig.json is added parameter "allowJs": true.
The markup is added to one of the component and css styles working too.
If I started the server the items overlap themselves.
It means the js doesn't start.
Obviously, I'm not understanding how to start the js in angular. Where to put the: var grid = new Muuri('.grid');
I have it in the xxx-component.ts but I got this error
https://www.dropbox.com/s/2hvl5fvq6g1s95t/error.jpg?dl=0
This is my hobby and I'm quite new in this technologies.
If someone has advice how to run this great gallery? Or sample project angular5+muuri It will be very helpful for me.
Thank you & Best regards
Jiri
hey, @JoxBubo. Check this -> 3rd Party Library Installation. Works fine for me, hope that would be helpful!
Hello @JoxBubo
Using const Muuri = require('muuri'); instead of import {Muuri} from 'muuri'; fixed this error for me. Hope it helps you.
@petajamaja import Muuri from 'muuri'; should also work.
@niklasramo
Unfortunately I tried that as well, and it didn't work.
Oh, that's weird. I wonder why 🤔
Most likely the reason for this is because Angular uses typescript and there are no type definitions defined by default. That's why we need to use either the typeless module declaration or using require.
You can try with typescript's allowSyntheticDefaultImports in your tsconfig.json.
@JoxBubo Were you able to fix this? I'm having the same issue :thinking:
I ran into this before and solved it by importing everything as an alias, and using 'default'. For your case, it would be something like this:
import * as Muuri form 'muuri';
â‹®
const grid = Muuri.default('.grid');
â‹®
Hope this helps!
I continue learning angular and working on my Angulag6 simple layout
so I don't have any solution.
But the @mriess260 example is excellent, thank you.
Try with declare var Muuri;
Hope this helps!
It' too late to reply on this but check line 2 (https://www.dropbox.com/s/2hvl5fvq6g1s95t/error.jpg?dl=0), it should be "import { Muuri } from 'muuri';"
Seems like this one can be closed.
Most helpful comment
I ran into this before and solved it by importing everything as an alias, and using 'default'. For your case, it would be something like this:
import * as Muuri form 'muuri';
â‹®
const grid = Muuri.default('.grid');
â‹®
Hope this helps!