title: Unit test for nested controllers
body: <p>I'm trying to write a unit test for a controller that's nested, but can't figure out how to mock the same behaviour in my test.</p>
  
  <p>I have 2 controllers:</p>
  
  <pre><code>function FirstController ($scope) {
      $scope.childs = [{
           title : 'Hello, earth!'
      }];
  };
  
  function SecondController ($scope) {
      $scope.child.title = $scope.child.title + $scope.$index;
  };
  </code></pre>
  
  <p>And in my HTML:</p>
  
  <pre><code>&lt;div data-ng-controller="FirstController"&gt;
      &lt;div data-ng-repeat="child in childs" data-ng-controller="SecondController"&gt;
          {{ child.title }}
      &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>And this works as expected (<a href="http://jsfiddle.net/tcayp/1/" rel="nofollow">http://jsfiddle.net/tcayp/1/</a>)</p>
  
  <p>The unittests:</p>
  
  <pre><code>// FirstController
  it('Should have childs', function () {
      scope = {};
      ctrl = new FirstController(scope);
      expect(scope.childs.length).toBeGreaterThan(0);
  });
  // SecondController
  it('Should have inherited a child', function () {
      scope = {};
      ctrl = new SecondController(scope);
      expect(scope.child.title).toEqual('Hello, earth!0');
  });
  </code></pre>
  
  <p>In the SecondController-test I can't figure out how to mock the inherit chain from ng-repeat.</p>