Get Dynamic Gallery Images
See original GitHub issueHi @lukasz-galka, Can you please help me, I need to clarify, I’m just a bit confused as to How can we make getting Gallery Images dynamic? I find myself in a situation where I need to get the URL of images from the database.
Here’s what I got:
getGalleryImages() {
this.galleryImages = [
{
small: `${product.images.AP.front}`,
medium: `${product.images.AP.side}`,
big: `${product.images.AP.back}`
}
]
}
But this definitely doesn’t work in the Component file, it’s not compiled because TypeScript doesn’t recognize what is AP, it returns undefined
for AP
except in the template.html like so {{ product.images.AP.front }}
How can you help me achieve my goal of making this dynamic, either in the component file or in the template file?
BTW, here’s an example of what my Image Object from the database looks like:
"images": {
"AP": {
"side": "http://vendors.blankstyle.com/ap/data/Hi-Res%20Web%20Images/5066bt_sd_mg.jpg",
"front": "http://vendors.blankstyle.com/ap/data/Hi-Res%20Web%20Images/5066bt_mg.jpg",
"back": "http://vendors.blankstyle.com/ap/data/Hi-Res%20Web%20Images/5066bt_mg.jpg"
}
}
Thanks in advance for your help and suggestions.
Issue Analytics
- State:
- Created 6 years ago
- Comments:15 (4 by maintainers)
Top Results From Across the Web
Create Dynamic Image Gallery with Database using ...
Create Dynamic Image Gallery with Database using jQuery, PHP & MySQL · Create Database Table. To store image file information a table needs...
Read more >Solved: How to dynamically change Gallery Image
Solved: Hi I've inserted a gallery that gets the data from a SharePoint List. I wanted to change the item image in the...
Read more >dynamic image gallery - php - Stack Overflow
Very simple auto gallery script, photos.php: <?php function getDirTree($dir,$p=true) { $d ... the folder that get displayed is the $path.
Read more >Dynamic galleries - Google Web Designer Help
Dynamic galleries. You can use groups to display multiple dynamic elements within each frame of a Swipeable Gallery or Carousel Gallery. For example,...
Read more >How To Create A Dynamic Gallery In WordPress - FooPlugins
A dynamic gallery is a photo gallery on your site, where the images update to show new content based on changes made to...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
You have
undefined
inconsole.log
because at this moment you don’t have product. Your code is likeIt is working in html because Angular is making change detection after every http request. So Angular knows that your response is end and is refreshing html. More here https://blog.thoughtram.io/angular/2016/02/22/angular-2-change-detection-explained.html
In html it looks like
<img src="undefined"></img>
<img src="photo.jpg"></img>
Imo your code should look
So you should create
galleryImages
array after response from server.Thanks, everything is fine now.