Retrieving an image from a JSON file based on its corresponding URL

I am trying to extract the URL and display it as an image:

This is how it appears in JSON:

https://i.sstatic.net/vpxPK.png

This is my HTML code:

<ul>
  <li *ngFor="let product of store.Products">

    <p>Product Image: {{ product.ProductImage }}</p>
    <p>Product Price: {{ product.Price }}</p>

  </li>
</ul>

Is there a way to achieve this using a pipe?

Answer №1

Upon reviewing the JSON you provided, I noticed there is a space that needs to be addressed.

<p>Product ProductImage: {{ product["Product ProductImage"] }}</p>
<p>Product Price: {{ product.Price }}</p>

To display an image, you will need to replace the code with an image tag.

<p><img [src]="product["Product ProductImage"]" /></p>
<p>Product Price: {{ product.Price }}</p>

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

Converting a TypeScript array into a generic array of a specific class

I am attempting to convert a JSON source array with all string values into another array of typed objects, but I keep encountering errors. How can I correct this code properly? Thank you. Error 1: There is an issue with converting type '({ Id: string ...

Updating code to insert elements into an array/data structure using Javascript

Hey everyone, I'm new to Javascript and I'm trying to make a change to some existing code. Instead of just returning the count of elements, I want to add each of the specified elements to an array or list. Here is the original code from a Seleni ...

Preventing unauthorized users from accessing routes and child components in Angular 2

Here is the project structure: AppComponent Nav Component LoginComponent Once the user successfully authenticates through the form connected to Firebase, they are directed to the section accessible only by logged-in users. AccountComponent Profile ...

Obtaining the Froala text editor's instance in React: A step-by-step guide

Is there a way to access the Froala editor instance within my React components? I've noticed that the official Froala documentation doesn't provide instructions for achieving this in React, only in jQuery. ...

When transitioning from Angular5 to Angular6, it seems that the angular.json file has not been properly updated

I am looking to transition from Angular5 to Angular6, following the guidance provided in this answer My attempt to update .angular-cli.json to angular.json using three commands did not yield the expected results: npm install -g @angular/cli npm install @ ...

Change the class of <body> when the button is clicked

One of my tasks involves adding a button that, when clicked, should give the body the class "open-menu". Implementing this using jQuery was quite straightforward - I just needed to add the following line of code: $('.burger').click(function() ...

What is the best way to target the first child element in this scenario?

Is there a way to target only the p tag with id="this" using .root p:first-child selector? Here is the code snippet: Link to CodePen .root p:first-child { background-color: green; } p { margin: 0; } .container { display ...

The Angular ViewportScroller feature appears to be malfunctioning in the latest release of Angular,

TestComponent.ts export class TestComponent implements OnInit, AfterViewInit { constructor( private scroller: ViewportScroller, ) {} scrollToAnchor() { this.scroller.scrollToAnchor('123456789'); } } HTM ...

Stop images from constantly refreshing upon each change of state - React

Within my component, I have incorporated an image in the following way: <div className="margin-10 flex-row-center"> <span> <img src={spinner} className="spinner" /> ...

Exploring deep within the layers to reach a component in Angular

In the hierarchy of components, I have a parent component that contains multiple other components. Among these nested components, there is a special component that I am particularly interested in. ParentComponent SubComponent1 MySpecialCom ...

What are the steps to overlay a button onto an image with CSS?

As a CSS newbie, I have a question that may seem silly or straightforward to some. I am struggling with placing a button over an image and need guidance on how to achieve this effect. Specifically, I want the button to appear like this blue "Kopit" button ...

Angular 5 - Implementing Horizontal Scroll with Clickable Arrows

In my Angular application, I have successfully implemented horizontal scrolling of cards. Now, I am looking to enhance the user experience by adding "Left" and "Right" buttons that allow users to scroll in either direction within their specific msgCardDeck ...

Steps to create a toggle feature for the FAQ accordion

I am currently working on creating an interactive FAQ accordion with specific features in mind: 1- Only one question and answer visible at a time (I have achieved this) 2- When toggling the open question, it should close automatically (having trouble with ...

The code seems to be malfunctioning in a separate JS file, but oddly enough, it functions properly when placed within a <script> tag

I am trying to create a loader, but I have encountered an issue where the script works when placed directly in the HTML file, but not when it is in a separate JavaScript file. Here is the script: var loader = document.getElementById("ld"); w ...

I'm having trouble with the calculator, unable to identify the issue (Typescript)

I'm struggling with programming a calculator for my class. I followed the instructions from our lesson, but it's not functioning properly and I can't pinpoint the issue. I just need a hint on where the problem might be located. The calculat ...

Positioning elements to the left and right of each other with CSS: tips and tricks

I'm currently working on aligning these elements one below the other, with one on the left and the other on the right: Here is my code snippet: Check out the fiddle here: https://jsfiddle.net/ak9hxfpt/2/ I want to position the test2 to the right sid ...

Different varieties of typescript variables

My variable is declared with two possible types. Consider this example: let foo: number | number[] = null; Then, I have an if condition that assigns either a single number or an array to that variable: if(condition) { foo = 3; } else { foo = [1,2,3 ...

Does Nativescript have a feature similar to "Hydration"?

It's been said that Phonegap offers an exciting feature called Hydration, which can lead to rapid and efficient deployments when combined with CD. Is it feasible to incorporate this concept into a Nativescript application? While I may not be well-ve ...

Creating a custom theme in MUI v5 by modifying ColorPartial members

I am seeking a solution to override certain members within PaletteOptions. My goal is to switch the type of grey from ColorPartial to PaletteColorOptions in order to include additional members. This was my attempt at implementing the necessary code: decl ...

I am experiencing difficulty in retrieving the content-disposition from the client

I am attempting to retrieve a .xlsx file that is generated on the backend using Spring Boot. I am able to retrieve headers on the frontend, which include the content-disposition as shown below. However, I am unable to access the content disposition in the ...