Variable substitution not functioning in ng-repeat AngularJS

When using ng-repeat to populate a list of images, I am encountering an issue with $index not replacing in the mouseover section but working fine in the name section. Can you suggest possible reasons for this inconsistency and how it can be corrected?

<img onmouseover="preview.src=img{{$index}}.src" name="img{{$index}}" src="{{image.SMALL_PATH}}" alt="" ng-repeat="image in images | filter:query"/>



<div class="preview" align="center">
    <img name="preview" src="images/img1.jpg" alt=""/>
</div>

Answer №1

To accomplish this task, you can utilize ng-src along with ng-mouseover. The code snippet below demonstrates how to implement it:

<img data-ng-mouseover="preview.src=image.src" name="image.name" data-ng-src="image.SMALL_PATH" alt="" ng-repeat="image in images | filter:query"/>

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

Troubleshooting: Issues with Adding a New Row in Datatables using JQuery

CSS : <div class="datatable-header"> <button type="button" name="add" id="add" class="float-right btn btn-info">Add</button> </div> <div class="table-responsive"> <table ...

Utilizing the powerful combination of AngularJS and Ionic, leverage the ng-repeat feature to seamlessly insert elements between

There are 2 loops in our code structure. They look like this: <ion-list> <ion-item ng-repeat="pair in items"> <div class="row"> <ion-item ng-repeat="item in pair" class="col-45"> {{item}} ...

Using Vue's forEach method in a computed property

I am currently working on a checkbox filter function that saves the value of clicked checkboxes in an array. However, I am encountering issues with updating the computed data as it is always returning undefined. The structure of the data: Casino { brand_ ...

What could be causing npm to not recognize my module in the "require" statement?

Currently, I am in the process of developing an npm module and conducting tests before making it available to the public. The method I am following is outlined in a blog post found at this link. However, I am encountering difficulties when trying to requir ...

What is the process for generating an Electronic Program Guide for television?

Welcome to the forum! I'm a front-end developer at a company for 6 months now, currently working on a TV app. It's my first experience in this field and I'm facing some challenges, particularly with creating an epg for the app. Unfortunately ...

Is AngularJS compatible with Mozilla Firefox version 3.0.11?

Can anyone confirm if the AngularJS is compatible with Mozilla Firefox version 3.0.11? I have built an application using AngularJS, but it's not functioning properly in this particular browser version. Could you please advise on the minimum version of ...

What is the process of decoding a URL in JavaScript?

Is there a better method to decode this URL in order to use it with JavaScript? URL: https://www.example.com/post.php?v=1&text=it's-me&20hello%0Aworld%0A At present, any occurrence of ' in the URL is causing an error and blank lines ar ...

Utilizing the default values in a Pebble AppSync Tuple

After making a few adjustments to the Pebble weather example program, I encountered an issue. I included some app_log calls for debugging purposes, and I decided to utilize a configuration screen instead of an app to transmit data. However, the app_log cal ...

What is the best way to retrieve the returned value from a jQuery GET call?

I was looking to implement something along these lines: function example(); var result = example(); if(result == 1) However, in my example function, I am making a Get request and using a callback that is not returning the value correctly as the ...

Nested function unable to assign values to variables

I am currently working on a function in Discord.js that collects users who reacted to a message. I have managed to gather all the user IDs inside a nested function, but when trying to return the array to the caller, it does not seem to work as expected. He ...

struggling to correctly display json api data in javascript onto html

I am receiving a json API response from my JavaScript request. I can successfully print the output to the console and it appears properly formatted like this: { "id": "1", "name": "John" } However, when I try to display it on an HTML page, it looks l ...

Retrieving parameters from a class that is handed over from the constructor to a function by leveraging the rest parameter feature

I am encountering an issue where the Method is not reading the values in the arguments, despite my attempts to pass each argument through the constructor into the method for encryption. Could someone please point out what I might be doing wrong? class A ...

One jQuery plugin was functioning perfectly, while the other one was failing to work as expected

I am working on a simple HTML file that includes a heading and two empty div elements. <h1>Blablabla.</h1> <div id="div1"></div> <div id="div2"></div> These two divs need to be populated with SVG content generated usin ...

Eliminating the nested API call within a loop

After making an API call to retrieve a set of data such as a list of users, I noticed that I am implementing a for loop and within it, I am making another API call to obtain each user's profile details based on their ID. I understand that this approac ...

Enhancing PouchDB with new elements

Recently, I delved into the world of PouchDB and encountered a small issue. When attempting to update an item, a new one is created instead of updating the existing item. Here is my code snippet: Service .service('LocalDB', function($q){ ...

What causes an undefined outcome when a promise is fulfilled?

Could you help me understand something? const promise1 = new Promise((resolve, reject) => { setTimeout(() => { if(true) { resolve('success') } else { reject('failure') } }, 4000) }) promise1.then(resul ...

Scraping JavaScript Content Webpages with VBA

I'm attempting to extract a table from the Drainage Services Department website. I've written the VBA code below, but it doesn't seem to be working. I suspect that the issue lies in the fact that this particular table is generated using Java ...

Methods for displaying a placeholder in a semantic-ui-vue dropdown without using the multiple attribute

When utilizing the dropdown feature in semantic-ui-vue, I have encountered an issue where the placeholder option does not function unless the multiple attribute is included. You can view my sandbox demonstration at this link. I have set up 2 dropdowns: ...

Shifting Icon to the Right within the Drawer Navigator Toolbar

While modifying the example code for Material UI's drawer navigator, I decided to enhance it by adding a notification icon and a checkout icon with the Admin Panel typography in the toolbar. However, I encountered an issue where the checkout icon app ...

Retrieve the complete HTML content of a webpage, including the values of all input fields

I'm attempting to save the entire webpage as an HTML file, including all previously entered values in input fields. I have already tried this method: $("#content").html(); However, it does not retain the values entered into input fields. $("#conten ...