Angular js preloads the background before displaying the image

Hey there! I have a question. When I load the page, I notice that the background of the "images class" loads before the ng-src image is loaded. Is there a way to fix this issue using Angular js?


    <div class="images" >
         <img ng-if="expression" class="imgclass" ng-src="{{vm.src  ||  '//:0' }}" /> 
             <img ng-if="!expression" class="imgclass" ng-src="absolute url" /> 
     </div>

Answer №1

One possible solution is:

<div class="photos" ng-if="rendered===true" >
  <img ng-if="condition" class="photoClass" ng-src="{{vm.src || '//:0' }}" ng-init="rendered = true"/> 
  <img ng-if="!condition" class="photoClass" ng-src="absolute URL" ng-init="rendered = true"/> 
</div>

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

What might be causing the image links to malfunction on the server while functioning normally when offline?

Recently, I've been working on a website and after successfully testing it offline, I decided to put it online. However, I've run into an issue where some images are not showing up. What's even stranger is that the images that are appearing ...

Filter and arranging elements with Jquery

Recently, I started learning programming and javascript. I managed to create a tab menu using JQuery. You can check out my fiddle here I attempted to utilize the ng-repeat="chart in charts|filter:{category: 'Where'} loop with hopes of display ...

Concealing items in a loop using Javascript

I need assistance with this issue. I am trying to hide text by clicking on a link, but it doesn't seem to be working correctly. Even though I tried the following code, I can't figure out why it's not functioning as expected. Is there a diff ...

Styling elements using flexbox and various other divs

Looking to style a webpage with CSS to achieve this particular layout: https://i.sstatic.net/K3x0A.png The objective is to make the page responsive where the red and blue columns (left and right) have fixed widths. The center column should be collapsible ...

Top methods to manage 'No Internet Connection' issue in an Angular, Ionic, Cordova application

Although I have seen similar questions asked before, I have yet to find a satisfactory answer. Therefore, I am presenting my issue here. I have developed an app that utilizes REST API calls to fetch data from a server. The app consists of 4 primary list v ...

Symbols in the URL undergo hexadecimal conversion while the page is loading

Whenever I click on a link, the URL changes abruptly during the page loading process. For example, when I click on a link like www.test.com/main#/?arg1=1&arg2=2, it initially appears in the URL bar. However, as the page loads, the URL suddenly transfo ...

Split the pane into divisions with a minimum width restriction

Is there a way to have two divs at 50% width, even if the content of the first div has a minimum size? <div class="col-xs-6"> <div style="min-width:1000px"> <label>The value here...</label> </div> </d ...

Stay afloat at the bottom of the webpage without using xhtml

Currently working on Moss 2007 and in need of creating a floating button at the bottom of the screen. This button should move down as I scroll down and up when scrolling back up. Although it can be easily achieved with xhtml, the challenge lies in not bei ...

Challenges with Adjusting Background Opacity in CSS

My text has a white background with an opacity of .3, but it's affecting the foreground due to CSS repositioning. Even though the HTML is in a different division, I struggle with certain aspects of CSS and would appreciate guidance from those more exp ...

Using AngularJS $resource with a JSON file for mocking data

My factory code looks like this: app.factory('AccordDepartement', function($resource, HttpCache) { return $resource('mocks/departements.json', {}, { query: { isArray: true, ...

Having trouble with Selenium-Java clicking on a date picker

My goal is to interact with a date picker text box in order to bring up a calendar where I can select a date. I am able to locate the element easily thanks to its "id" attribute. If I manually click on the textbox, the calendar pops up as expected. Howe ...

Having trouble displaying dynamically added images in my jsx-react component. The images are not showing up as expected

import React from "react"; import ReactDOM from "react-dom"; var bImg = prompt("Enter the URL of the image you want to set as the background:"); const bStyle = { backgroundImage: "url(bImg)"; // The link is stored ...

Guide to creating a dynamic column layout with minimum height divs

I am facing an issue with the variable height of my div, causing it to position incorrectly. To demonstrate the problem, I have included a code snippet below. Here is the solution I am seeking: https://i.sstatic.net/XMAMr.png Note: Since the div has a ...

When a custom icon is clicked in the vue-select dropdown, the custom method is not activated

In my current project, I am creating a vue-component based on vue-select. Within this component, I have added a custom info Icon. The issue I am facing is that when the user clicks on the Icon, instead of triggering my custom method getInfo, it opens the s ...

Nested divs with CSS padding inside

I'm curious about the excessive padding above and below the text in this fiddler box. http://jsfiddle.net/fZ6d7/1/ CODE <style> .simplebox { padding: 6px; background: #eee; border-radius: 8px; border: 1px ...

Ways to eliminate the default padding in Ant Design

I have implemented a collapsible sidebar. However, the content inside the sidebar is automatically adding padding values of 16px on the top, right, bottom, and left. I want to remove this automatic padding. render() { return ( <div className="common ...

Text enhancement with text-shadow in jQuery and CSS

Before I reached out, I had been searching for a solution. In the process of building my website, I decided to incorporate text-shadow. It seemed straightforward, but turned out to be more complicated than expected. I discovered that IE does not support ...

Angular - why ng-keydown is not correctly enforcing validation?

Take a look at this jsFiddle (Please note that the ng-keydown function isn't triggering, but that is not the main issue in the example) I'm attempting to implement validation for an input box so that only numbers from 0 to 100 are allowed using ...

Applying Angular's grouping feature while looping through records in a dropdown menu

If, for example, I receive data in JSON format like the following: [ { "id": 10, "session": "test2", "event": "Event 2" }, { "id": 11, "session": "TEST 22", "event": "Event 2" }, { "id": 9, "session": "test 1", "event": "Event 1" } ] My goal is to organi ...

Exploring the Potential of Mobile Development using AngularJS

I am in the process of creating an app with the following key design objectives: Efficiency and modularity - a light core that can be expanded to create a feature-rich app in a cohesive manner Mobile focus - this app is primarily aimed at mobile platform ...