angular2-masonry icon indicating copy to clipboard operation
angular2-masonry copied to clipboard

masonry is not a constructor

Open petrck opened this issue 10 years ago • 4 comments

Hi, i got error with using masonry with angular 2.0 release. The problem is in masonry.ts on line 60:

this._msnry = new masonry(this._element.nativeElement, this.options);

Error message from console:

EXCEPTION: Error in /angular/views/app.html:13:11 caused by: masonry is not a constructor ORIGINAL EXCEPTION: masonry is not a constructor

TypeError: masonry is not a constructor
    at AngularMasonry.ngOnInit (masonry.ts:60)
    at DebugAppView._View_ChatComponent0.detectChangesInternal (ChatComponent.ngfactory.js:145)
    at DebugAppView.AppView.detectChanges (core.umd.js:9566)
    at DebugAppView.detectChanges (core.umd.js:9671)
    at DebugAppView.AppView.detectViewChildrenChanges (core.umd.js:9592)
    at DebugAppView._View_ChatComponent_Host0.detectChangesInternal (ChatComponent_Host.ngfactory.js:36)
    at DebugAppView.AppView.detectChanges (core.umd.js:9566)
    at DebugAppView.detectChanges (core.umd.js:9671)
    at ViewRef_.detectChanges (core.umd.js:7668)
    at eval (core.umd.js:7089)

in my app.html:

     <masonry>
            <masonry-brick class="brick" *ngFor="let post of posts">
                <!--<post  [post]="post">Component loading...</post>-->
            </masonry-brick>
        </masonry>

Is it bug or what is wrong? Tranks

petrck avatar Oct 01 '16 08:10 petrck

What module loader-system are you using? I've tried it with both systemjs and webpack without problem.

jelgblad avatar Oct 03 '16 08:10 jelgblad

@jelgblad Systemjs, but i finally used only masonry lib and it works well.

petrck avatar Oct 03 '16 10:10 petrck

@petrck OK. Getting ES5-libraries load in typescript with both webpack and systemjs isn't as straight forward as one might think.

This error says that masonry-layout isn't loaded into the masonry-variable properly:

EXCEPTION: Error in /angular/views/app.html:13:11 caused by: masonry is not a constructor
ORIGINAL EXCEPTION: masonry is not a constructor

I'm still interested if this issue is with systemjs or with this library. Can you paste your systemjs-configuration?

jelgblad avatar Oct 03 '16 12:10 jelgblad

@petrck can you please list your solution? I'm getting the same issue when trying to run tests through Jasmine and Karma and am at my wits end.

djohns2021 avatar Aug 22 '17 21:08 djohns2021