我是Angular的新手,正在使用Angular 8 我有JSON格式的“ dataSource”变量中的图像路径列表,如下所示:
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"}
How can i show all this images on HTML if my base url is "http://localhost" and file path is above in JSON.
Note: Image path may increase or decrease. Means this time 4 image i got, but if i get 5 image path. So how can i handle this?
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>