I am working on Ionic. I would like from a the side-menu to select (toogle) some criteria. Here is the html :
<div ng-app="app">
<div data-ng-controller="dishTypeListController">
<h1 class="featured_in_mag_name">Available filters criteria</h1>
<div class="listing_venue_types_filter_page">
<div class="input_dishtype_selection "
data-ng-repeat="dishType in dishTypeList"
ng-class="{'filter_selected':selection.indexOf($index) != -1}"
ng-click="toggle($index)">
{{dishType.name}}</div>
</div> <!-- listing_venue_types_filter_page-->
</div>
data is coming from an array :
var wmapp = angular.module('app', []);
wmapp.controller('dishTypeListController', function($scope) {
$scope.dishTypeList = [
{'name': 'Meat '},
{'name': 'Soup'},
{'name': 'Fish'},
{'name': 'Fruits'},
{'name': 'entree'},
{'name': 'snack'}
];
$scope.selection = [];
$scope.toggle = function (idx) {
var pos = $scope.selection.indexOf(idx);
if (pos == -1) {
$scope.selection.push(idx);
} else {
$scope.selection.splice(pos, 1);
}
};
})
How can I indicate the toogling on the objects above are to be used as a selection-criterias to print a ng-repeat ?
I had tried tp put a jsfiddle together to illustrate without beeing able to complete it, https://jsfiddle.net/bmun0mkx/ Hope this is clear thanks a lot for your help.