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 →

Some time back I was looking for multi select checkbox group option in angularjs. I could not able to find my self on stackoverflow, Since i have developed it and sharing here js fiddle link.

<div ng-app="check">
<div ng-controller="controller">
<ul>
    <li ng-repeat="(key, item) in basket"> {{item.type}}
      <ul>
        <li ng-repeat="(sub_catkey, sub_catval) in item.fields">
            <label>
              <input type="checkbox" ng-model="sub_catval.checked" /> {{sub_catval.name}}  -- {{sub_catval.checked}} | json
            </label>
        </li>
      </ul>
    </li>

</ul>
Selected show here
<li ng-repeat="(key, item) in basket"> {{item.type}}
  <ul>
    <li ng-repeat="(sub_catkey, sub_catval) in item.fields | filter: true">
      <label>
        {{sub_catval.name}}  -- {{sub_catval.checked}}
      </label>
    </li>
  </ul>
  </li>
    {Manager: {Name: filter.key}}
    {{basket}}

angular.module('check', []) .controller('controller', function($scope) {

        $scope.basket = [
        {
        "type": "fruits",
        "fields": [
            {name: 'Apple', checked:false},
          {name: 'Mango', checked:true},
          {name: 'Banana', checked:false},
          {name: 'Guava', checked:false},
          {name: 'Orange', checked:false}
        ]
      },
      {
        "type": "flowers",
        "fields": [
            {name: 'rose', checked:true},
          {name: 'lilly', checked:false},
          {name: 'tulip', checked:false},
          {name: 'marigold', checked:false},
          {name: 'sunflower', checked:false}
        ]
      }
    ];

    $scope.selected = {
        fruits: ["Apple"],
        flowers: []
    };



     $scope.checkAll = function() {
         $scope.basket = angular.copy($scope.basket);
      };
      $scope.uncheckAll = function() {
          $scope.selected.fruits = [];
      };
});

http://jsfiddle.net/42y83eLb/

share|improve this question
    
To comply with the SO format, you should have asked a question, then answered it your self. Then you would get points for the question AND the answer ;-) – Mike Aug 27 at 8:09
    
I am afraid it is not the place to share your code... – Joy Aug 27 at 9:00

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.