The Angular masonry directive is causing inner elements to disappear with an error message popping up: "Oh no! Masonry is

Having some difficulties implementing the Angular Masonry Directive by klederson in a project. The elements are taking up space in the body tag but not appearing visible, and an error message is being displayed in the console.

Including the masonry dependency:

angular.module("cardSite",['masonry'])

This is the markup I'm using to call masonry. Even when trying the JS approach, the same error persists.

<div masonry='{ "transitionDuration" : "0.4s" , "itemSelector" : ".grid-item"}' class="grid">
        <div masonry-tile class="grid-item">...</div>
        <div masonry-tile class="grid-item grid-item--width2">...</div>
        <div masonry-tile class="grid-item--height2">...</div>
        <div masonry-tile class="grid-item">...</div>
        <div masonry-tile class="grid-item">...</div>
        <div masonry-tile class="grid-item grid-item--width2">...</div>
        <div masonry-tile class="grid-item--height2"></div>
        <div masonry-tile class="grid-item">...</div>
        <div masonry-tile class="grid-item">...</div>
        <div masonry-tile class="grid-item grid-item--width2">...</div>
        <div masonry-tile class="grid-item">...</div>
        <div masonry-tile class="grid-item">...</div>
        <div masonry-tile class="grid-item--height2"></div>
        <div masonry-tile class="grid-item grid-item--width2">...</div>
        <div masonry-tile class="grid-item">...</div>
        <div masonry-tile class="grid-item--height2"></div>
        <div masonry-tile class="grid-item">...</div>
        <div masonry-tile class="grid-item grid-item--width2">...</div>
        <div masonry-tile class="grid-item">...</div>
    </div>

Script is being called at the bottom of the page:

<script src="scripts/directives/angular-masonry-directive.js"></script>

URL of the relevant page:

Screenshot of the error: https://i.sstatic.net/EzXnT.png

Plunker link: https://plnkr.co/edit/vzhUUtKtrZWxCwMITOL6?p=preview

Answer №1

When the error message displays as

ReferenceError: Masonry is not defined
, it indicates that the problem does not lie with the directive. The issue arises because the function Masonry() is not present, suggesting that you may have forgotten to include http://masonry.desandro.com/

The root of the issue can be found in this line of code:

var masonry = scope.masonry = new Masonry(container, options);

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Customize default progress bar in browsers

One feature of my website allows users to update their personal information, profile image, background image, and more. After clicking the submit button, a loading screen appears with a progress percentage displayed at the bottom left corner of the page (i ...

Is there a way to provide a dynamic value for the p:remoteCommand ajax call?

My issue involves a p:dataTable that contains p:commandLink elements. I need to initiate an ajax call with parameters when the mouseover event occurs. After some research, it became clear that commandLink cannot trigger an ajax call on mouseover directly - ...

Strategies for setting up the runtime dynamically for Nextjs API routes

After deploying my Next.js 13 app on Cloudflare Pages, I encountered an issue with the API routes. To address this, I had to export the runtime variable from each route in the following manner. export const runtime = "edge" During local developm ...

What is the reason behind the appearance of 'Cannot Get/' when trying to render pug?

Attempting to configure a basic Express server with a simple pug template. Could you kindly point out what I might be doing incorrectly in this setup? 'use strict'; //Require Express var express = require('express'); var app = expres ...

Taking command of the UI from another module in Angular

I am in the process of creating a tutorial module using Angular for my regular angular module. This tutorial is designed to assist older users who may need some extra guidance on how to navigate the UI. My goal is to have the tutorial seamlessly integrated ...

What is the best way to show an image within a div using HTML and fetching data from an API response?

I am attempting to showcase an image within a div using HTML. I utilized fetch to retrieve the JSON data from the following API: . The response contains JSON data with the image URL labeled "primaryImage". While I can display it as text, I am encounterin ...

I am encountering an issue stating "indexRouter has not been defined"

Encountering an error "indexRouter is not defined" while attempting to run the code below. Despite attempts to remove the line, additional errors persist. Can anyone clarify the rationale behind using the common variable router for both index.js and user.j ...

How can I change an icon and switch themes using onClick in react js?

I have successfully implemented an icon click feature to change the colorscheme of my website (in line 21 and changeTheme). However, I also want the icon to toggle between FaRegMoon and FaRegSun when clicked (switching from FaRegMoon to FaRegSun and vice v ...

Can you please explain how to separate a collection of emails that have various formats using JavaScript?

My list of emails contains two formats: with name name <<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="395c5458505579585d5d4b5c4a4a175a5654">[email protected]</a>> without name <a href="/cdn-cgi/l/email-prote ...

Delete the <script> tag prior to running

I am attempting to eliminate additional <script> tags from the body using only pure javascript. The HTML structure of the page in question is as follows: <html> <head> <script type="text/javascript"> var scripts ...

How can I create a real-time page update using node.js?

I am completely new to node.js, but my main goal in learning this language is to achieve a specific task. I want to create a webpage where the content within a designated "div" can be swapped dynamically for users currently viewing the page. For example, ...

What is the process for converting plain text into an image tag using the methods ".replace()" and ".html()"?

My goal is to customize this particular answer so that it can transform classic BCCode [img]{url}[/img] into an HTML image. In the code snippet provided, I have successfully implemented something similar with [b]text[/b]. However, when attempting to use [i ...

Deciphering a PHP json_encode response using JavaScript

Consider this scenario where I am using json_encoding for my array and displaying it: $key = $this->key; $sql = "SELECT * FROM Requests"; $result = $this->db->query($sql); ...

Unable to run any npm scripts in a React project

My React application has been running smoothly for a while, but recently all the npm commands in the package.JSON file have stopped working. { "name": "fitness-appication-frontend", "version": "0.1.0", "private": true, "dependencies": { "reac ...

Retrieve information from an external source and subsequently make alterations to it

If a certain external site returns a string like "cost is 10$", is it possible for me to display it as "price:10$" on my own website using only Javascript? The external site could be something like Facebook.com. My website, of course, belongs to me. Hello ...

Ways to prevent browser scrolling on smartphones and tablets

Having a simple HTML file with an iframe embedded, I have been attempting to prevent my browser from scrolling in both documents. However, this solution works intermittently and does not provide consistent results. I have tried applying various event list ...

Property-based Angular Material row grouping in a mat-table is a powerful feature that enhances

Is there a way to organize the data in one row with the same ID? Currently, my data looks like this: Data Set: { "id": "700", "desc": "Tempo", "richiesta": "20220087", "dataElab": &quo ...

Issue with nav-pill not functioning properly on localhost server set up with XAMPP

<!-- Customized Navigation Pills --> <ul class="nav nav-pills" role="tablist"> <li class="nav-item"> <a class="nav-link active" data-toggle="pill" href="#home">My Home</a> </li> <li class="nav-item ...

Switch up image origin when image reaches screen boundary

I am trying to create a DVD screensaver with changing images each time it hits the edge, but I can't seem to get it to work. I've attempted using the code snippet below: var img = document.getElementById("myImage"); img.src = 'img/new-image. ...

Troubleshooting AJAX issues in Firefox with window.location.assign function

Here is my AJAX POST request that sends serialized form data to the server: // Handle form submission. $('#evaluationform').on('submit', function(e){ e.preventDefault(); ajaxObject = { url: $("#evaluationform").attr("a ...