<!DOCTYPE html>
<html ng-app="testApp">

  <head>
    <script data-require="angular.js@*" data-semver="1.3.0-beta.5" src="https://code.angularjs.org/1.3.0-beta.5/angular.js"></script>
    <link rel="stylesheet" href="style.css" />
    <script src="script.js"></script>
  </head>

  <body ng-controller="test">
    <h1>Hello Plunker!</h1>
    <label>Divisions Participating*</label>
    <div class="radio-check-wrap">
      <ul class="radio-check-group">
        <li ng-repeat="d in divisions">
          <input type="checkbox" ng-model="d.selected" class="" id="{{'div' + d.Id}}" name="selectedDivisions[]" />
          <label for="div{{$index}}">{{d.Description}}</label>
        </li>
        <ul>
          <li ng-repeat="s in d.subd">
            <input type="checkbox" ng-model="s.selected" class="" id="{{'div' + d.Id}}" name="selectedsubd[]" />
            <label for="div{{$index}}">{{s.Description}}</label>
          </li>
        </ul>
      </ul>
      {{tradeshow.Divisions|json}}
    </div>
  </body>

</html>

var testApp = angular.module('testApp', [])
.controller('test', ['$scope', 'filterFilter', 
  function($scope, filterFilter) {
    $scope.divisions = [
      { Description: 'test1', Id: 1 },
      { Description: 'test2', Id: 2 },
      { Description: 'test3', Id: 3 },
      { Description: 'test4', Id: 4 },
      { Description: 'test5', Id: 5 }
    ];
    
      $scope.subd = [
      { Description: 'sub1', Id: 7 },
      { Description: 'sub2', Id: 8 },
      { Description: 'sub3', Id: 9 }
    ];
    
    $scope.tradeshow = { };
    $scope.tradeshow.Divisions = [];
    
    // selected divisions
    //$scope.selection = [];
    
    // helper method
    $scope.selectedDivisions = function selectedDivisions() {
      return filterFilter($scope.tradeshow.Divisions, { selected: true });
    };
    
    // watch divisions for changes
    $scope.$watch('divisions|filter:{selected:true}', function (nv) {
      $scope.tradeshow.Divisions = nv.map(function (division) {
        return {Id: division.Id};
      });
    }, true);
  }
]);
/* Styles go here */