I have displayed products in divs and users can click on them, to select them. The problem i have is that only one product can be selected. I wan't to change this functionality to be multi selected and function should collect id's of products.
This is my HTML for products
<div class="product_item hit w_xs_full" ng-repeat="p in products track by $index" style="float: left; background-color: blue;">
<figure class="r_corners photoframe type_2 t_align_c tr_all_hover shadow relative"
ng-click="selectUserItems($index)" ng-class="{sel: $index == selected}">
<!--product preview-->
<img ng-src="images/products/{{p.images[0].thumbName}}" alt="{{p.name}}" class="tr_all_hover">
<!--description and price of product-->
<figcaption>
<br>
<h5 class="m_bottom_10"><b>{{p.name}}</b></h5>
<p class="scheme_color f_size_large m_bottom_15" style="color:black;">Located in: <b>{{p.country}}</b></p>
<a href="#/swap/{{p.mainCategorieLink}}/{{p.subCategoryLink}}/{{p.alias}}">
<button class="button_type_4 bg_scheme_color r_corners tr_all_hover color_light mw_0 m_bottom_15">See item</button>
</a>
</figcaption>
</figure>
</div>
And this is my controller function for selecting items
//select items
$scope.selectUserItems = function(index){
$scope.selected = index;
};
Once item is selected background of div is colored blue
.sel {
background-color:#5ACBFF;
}
So how to properly write controller function so you can select multiple divs and $scope.selectd variable collects ids of products.