title: angularjs checkbox ng-checked not working
body: <p>I have the following code :-</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html lang="en"&gt;
  &lt;head&gt;
      &lt;link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css"&gt;
      &lt;script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.4/angular.min.js"&gt;&lt;/script&gt;
  &lt;/head&gt;
  &lt;body ng-app="app" ng-controller="ctrl" ng-init="init()"&gt;
    &lt;div class="container" style="width:400px"&gt;
      &lt;div class="panel panel-default"&gt;
        &lt;div class="panel-body"&gt;
          &lt;form&gt;
              &lt;div class="form-group"&gt;
                &lt;label for="selectedBasket"&gt;Select basket :&lt;/label&gt;
                &lt;select id="selectedBasket" class="form-control" ng-model="selectedBasket" ng-options="b.name for b in baskets"&gt;
                &lt;/select&gt;
              &lt;/div&gt;
              &lt;div ng-repeat="f in fruits" class="checkbox"&gt;
                &lt;label&gt;
                  &lt;input type="checkbox" value="" ng-checked="selectedBasket !== null &amp;&amp; selectedBasket.items.indexOf(f) !== -1"&gt;
                    {{ f }}
                &lt;/label&gt;
              &lt;/div&gt;
          &lt;/form&gt;     
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  
    &lt;script&gt;
    var app = angular.module('app', []);
    app.controller('ctrl', function($scope) {
      $scope.init = function() {
        $scope.baskets = [{'name': 'mary', 'items': ['apple', 'orange']}, {'name': 'jane', 'items': ['banana']}];
        $scope.fruits = ['apple', 'banana', 'cherry', 'orange', 'watermelon'];
        $scope.selectedBasket = null;
      };
    });
    &lt;/script&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>if I select Mary or Jane, I can correctly see the correct items in their basket checked. However if I manually check all the fruits and then look at Mary or Jane, it doesn't exclude the items that are not in their baskets. Why is ng-checked failing?</p>
  
  <p>Bonus question, is it best practise to set selectedBasket to null and checking for null in a directive assuming I want nothing as a default value, is there a better way?</p>