Dismiss
Announcing Stack Overflow Documentation

We started with Q&A. Technical documentation is next, and we need your help.

Whether you're a beginner or an experienced developer, you can contribute.

Sign up and start helping → Learn more about Documentation →

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.

share|improve this question
    
Updated the jsfiddle using the angular pub/sub mechanism. jsfiddle.net/bmun0mkx/1 – shakib Mar 23 '15 at 5:42
    
thanks @shakib struggling now with implementation locally, but jsfiddle works as wanted – lauWM Mar 23 '15 at 8:22

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.