我正在开发一个具有收藏夹部分的Web应用程序,但是当我单击心脏图标时,它将反映所有部分。基本上,我希望单击ng-repeat时唯一的心脏发光。为了更好地理解,我输入了代码。
addFav:function(id,index){
vm.wishListData.venue_id=vm.searchResults[index]._id;
var objRequest=filterMapperService.addFavData(vm.wishListData);
filterListService.addFavData(objRequest).then(function (response) {
if (response && response.data) {
if(response.data.status=='200'){
alert("Added to Favourite");
vm.addToFav=1;
}
}
})
},
removeFav:function(index){
vm.wishListData.venue_id=vm.searchResults[index]._id;
var objRequest=filterMapperService.removeFavData(vm.wishListData);
filterListService.removeFavData(objRequest).then(function (response) {
if (response && response.data) {
if(response.data.status=='200'){
alert("Removed from Favourite");
vm.addToFav=null;
}
}
})
},
<div uib-carousel active="active" interval="5000" no-wrap="noWrapSlides" ng-if="result.venue_images.length">
<div uib-slide ng-repeat="img in result.venue_images" index="$index">
<img ng-src="{{vm.ip}}/images/{{img}}" style="margin:auto;" style="height:200px;">
</div>
</div>
<div class="addFavButton" ng-click="vm.addFav(result.venue_id,$index)" ng-if="!vm.addToFav">
<img src="/icons/remove-fav.png" style="height: 30px;">
</div>
<div class="addFavButton" ng-click="vm.removeFav(result.venue_id,$index)" ng-if="vm.addToFav">
<img src="/icons/add-fav.png" style="height: 30px;">
</div>
我不知道在特定时间显示或隐藏特定的div或图标。