As a beginner in Angular, I am currently working with Angular 8. I have a list of image paths stored in the 'dataSource' variable in JSON format, like so:
hotdeals: Array(4)
0: {uri: "/Home/HotDeals/hotdeal1.png", id: "2"}
1: {uri: "/Home/HotDeals/hotdeal2.png", id: "3"}
2: {uri: "/Home/HotDeals/hotdeal3.png", id: "4"}
3: {uri: "/Home/HotDeals/hotdeal4.png", id: "6"}
I am wondering how to display all these images on HTML, considering my base URL is "http://localhost" and the file paths are as mentioned in the JSON above.
Note: The number of image paths may vary. For example, if I receive 5 image paths, how can I handle that dynamically?
dashboard.component.html
ngOnInit()
{
this.apiService.getHotDeals('pop').subscribe(home=>{
this.dataSource=home;
console.log(this.dataSource);
}
dashboard.component.html
<owl-carousel [options]="{items:3, dots:true, navigation:true}"
[carouselClasses]="['owl-theme', 'row', 'sliding']" >
<div class="best-deals-single"><a><img src="{{this.dataSource}}" height="300" width="200" alt=""></a></div>
</owl-carousel>
Here's a screenshot of the console displaying the 'dataSource': https://i.sstatic.net/LTvb6.png