What is the best way to incorporate Ekko Lightbox into an Angular 7 Project?

I'm facing an issue while implementing Ekko lightbox in my angular project. Specifically, I want to use it in a certain component but I am unsure about how to import the necessary files into that component.

After installing Ekko via NPM, I found all the files listed under "node_modules/Ekko-lightbox".

The documentation for Ekko can be accessed here:

Below is my Angular Component code. (I have already imported Jquery and added the function code within NgOnInIt)

import { Component, OnInit } from '@angular/core';
declare var $:any;

@Component({
  selector: 'app-graphic-design',
  templateUrl: './graphic-design.component.html',
  styleUrls: ['./graphic-design.component.css', '/node_modules/ekko-lightbox/dist/ekko-lightbox.css']
})
export class GraphicDesignComponent implements OnInit {

  constructor() { }

  ngOnInit() {
    $(document).on('click', '[data-toggle="lightbox"]', function(event) {
      event.preventDefault();
      $(this).ekkoLightbox();
  });
  }

}

I have also included the HTML sample code provided in the documentation in my component's HTML file

<a href="https://unsplash.it/1200/768.jpg?image=251" data-toggle="lightbox">
  <img src="https://unsplash.it/600.jpg?image=251" class="img-fluid">
</a>

Although the image pops up, clicking on it doesn't trigger any action and it doesn't appear responsive either.

Moreover, despite linking the scripts and CSS files in my angular.json file, the functionality still isn't working as expected.

https://i.stack.imgur.com/zRrrv.png

Answer №1

Make sure to add the necessary lightbox style and script files within the angular.json file for it to function properly.

"styles": [
  "lightbox.css",
  "custom-styles.css"
],
"scripts": [
  "lightbox.js"
]

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

Is there a way to verify if the object's ID within an array matches?

I am looking to compare the ID of an object with all IDs of the objects in an array. There is a button that allows me to add a dish to the orders array. If the dish does not already exist in the array, it gets added. However, if the dish already exists, I ...

Angular 7: Implementing a Dynamic Search Filtering System

I'm looking to create a versatile filter in Angular 7 that can perform search operations on any field across multiple screens. Custom pipe filters I've come across only seem to work with specific static fields, limiting their use. Let me provide ...

Angular Error - TS2322: The specified type of 'Object | null' cannot be assigned to 'NgIterable<any> | null | undefined'

I encountered an error in homes.component.html while trying to run my Angular project to showcase a list of homes from a JSON file. https://i.stack.imgur.com/D0vLQ.jpg Json File [ { "image_url": "https://images.unsplash.com/ph ...

The function cloneElement does not share any properties with the type Partial<P> and Attributes

I'm encountering a perplexing issue with my code. When I attempt to call cloneElement with the second parameter being of type Type { foo: number } has no properties in common with type 'Partial<Child> & Attributes', TypeScript thro ...

Using TypeScript to set an HTMLElement in a web page

Currently in the process of transitioning my old JavaScript code to TypeScript. One of the components I have is a Table Of Contents JSX component that helps me navigate easily to specific headings. I had a function that calculated the total offset needed ...

The element type 'x' in JSX does not offer any construct or call signatures

I have recently imported an image and I am trying to use it within a function. The imported image is as follows: import Edit from 'src/assets/setting/advertising/edit.png'; This is the function in question: function getOptions(row) { ...

Incompatible parameter type for the Angular keyvalue pipe: the argument does not match the assigned parameter type

I need to display the keys and values of a map in my HTML file by iterating over it. To achieve this, I utilized Angular's *ngfor with the keyvalue pipe. However, I encountered an error when using ngFor: The argument type Map<string, BarcodeInfo ...

Consider the presence of various peer dependency versions in a react-typescript library

Currently, I am in the process of converting my react component library react-esri-leaflet to typescript. This library requires the user to install react-leaflet as a peerDependency and offers support for both react-leaflet version 3 (RLV3) and react-leafl ...

Tips on running methods consecutively within ngOnInit in Angular

I'm currently working on an ngoninit function that contains four methods. Two of these methods are responsible for retrieving data from the API, while the other two are intended to load this data when the page loads. ngOnInit(){ getname(); getsubjects ...

A guide on specifying the data type for functions that receive input from React Child components in TypeScript

Currently, I am faced with the task of determining the appropriate type for a function that I have created in a Parent Component to retrieve data from my Child Component. Initially, I resorted to using type: any as a solution, although it was not the corr ...

Issue with closing the active modal in Angular TypeScript

Can you help me fix the issue with closing the modal window? I have written a function, but the button does not respond when clicked. Close Button: <button type="submit" (click)="activeModal.close()" ...

Learn how to access nested arrays within an array in React using TypeScript without having to manually specify the type of ID

interface UserInformation { id:number; question: string; updated_at: string; deleted_at: string; old_question_id: string; horizontal: number; type_id: number; solving_explanation:string; ...

Struggling to find the definition of a Typescript decorator after importing it from a separate file

Consider the following scenario: decorator.ts export function logStuff(target: Object, key: string | symbol, descriptor: TypedPropertyDescriptor<any>) { return { value: function (...args: any[]) { args.push("Another argument ...

Show the quantity of chosen selections utilizing ng-select

I have implemented the ng-select component for users to select multiple options from a list. My goal is to have the selected option displayed normally when only 1 option is chosen. However, if 2 or more options are selected, I want a custom template to sh ...

Guide for adjusting icon dimensions in Material-UI breakpoints

import { Container } from "@mui/material"; import * as React from "react"; import { Home } from "@mui/icons-material"; import PersonIcon from "@mui/icons-material/Person"; import FormatListBulletedIcon from "@mu ...

Enhancing Efficiency: Streamlining Editing in KendoUI Grid for Angular 2/4

According to the information provided on this link, it seems that batch editing of the kendo ui grid for angular 2/4 is currently unavailable. Is there anyone who has come up with a solution or workaround for this issue? ...

What could possibly be causing routing issues in Angular 2?

Can anyone explain to me why the routing feature is not functioning properly in Angular 2? I am attempting to display a component when the URL path is empty. Below is the code snippet: http://plnkr.co/edit/Vgc2bB7Lc8h9XsuhIg6X?p=preview import { NgModul ...

What could be causing my controller method in TypeScript to throw an error message unexpectedly?

Hey there. I'm diving into TypeScript and currently working on converting an Express backend to TS. Everything was smooth sailing until I encountered some unexpected issues. Specifically, the lines const hasVoted = poll.votedBy.some((voter): boolean = ...

Getting the PlayerId after a user subscribes in OneSignal with Ionic2

Currently working on an app with Ionic2 and facing a challenge with retrieving the player id after a user subscribes in order to store it in my database. Any suggestions on how I can retrieve the unique player id of OneSignal users post-subscription? ...

Is there a syntax available for type annotation of arrays created from pre-declared variables?

According to my standards, all possible annotations are required in TypeScript. Therefore, TypeScript-ESLint is prompting me to annotate the `[ responseData, cognitoUser ]`. However, when I try to use the syntax `[ responseData1: ResponseData1, responseD ...