我有一个数组,它是一个像对象一样的对象:
$scope.dishList = [
{ nameEnglish: 'onion soup',
nameLocal: 'soupe a loignon',
description: 'xxxxx',
region: 'vanitia',
itemid: 'IT022',
cuisineTypeIsoCode: 'IT',
imageSource: '( "img/" + dish.cuisineTypeIsoCode + "/" + dish.itemid + "small.jpg")',
}
// some more similar objects
];
每个图像名称构造如下“IT001small.jpg,IT002small.jpg等,并存储在img / {{cuisineTypeIsoCode}} / img.pjg
我想在该数组中包含图像的路径,以便我可以在我的HTML模板中使用此参数和{{dish.imageSource}}语句(见下文)
<article class="item_frame">
<a class="" href="#"><img class="bookmark_icon" src="img\bookmark_plus_whitev3.png">
</a>
<img class="item_main_image" ng-src="{{dish.imageSource}}">
<img class="item_icon_circled" src="img/dishiconv4orangecircled.png">
<h1 class="item_name_english">{{dish.nameEnglish}}</h1>
<h2 class="item_name_local_language">{{dish.nameLocal}}</h2>
<p class="item_description ">{{dish.description}}</p>
<div class="subcuisine_container_w_flag">
<span class="subcuisine_text_in_dish_pages"> | {{dish.region}}</span>
<img class="flag_in_dishpages" src="img/flag.png">
</div>
</article><!--main article frame 1 -->
我已经尝试过几件事,但却无法正常工作......有什么想法吗? 感谢
答案 0 :(得分:1)
不是确切答案,但更好的替代方法,我认为您可以替换为以下一个:
<img class="item_main_image" ng-src="img/{{dish.cuisineTypeIsoCod}}/{{dish.itemid}}small.jpg">
快乐帮助!