title: AngularJS: Scope in ng-repeat
body: <p>I am trying to ng-include some partials dynamically.  I realize there may be other ways to do this, but I want to understand why this way isn't working.</p>
  
  <p>I have a controller defined as so:</p>
  
  <pre><code>auditApp.controllerModule.controller('LayoutCtrl', ['$scope',
      function (scope) {
          scope.index1={
              pages:[
                  'views/subpage1.html',
                  'views/subpage2.html',
                  'views/subpage3.html',
                  'views/subpage4.html'
          ]};
      }
  ]);
  </code></pre>
  
  <p>If I execute a static version of my code, everything works fine:</p>
  
  <pre><code>&lt;div ng-controller="LayoutCtrl"&gt;
      &lt;div class="row" ng-init="pob={pageidx:0}"&gt;
          &lt;div class="span1"&gt;
              &lt;ul class="nav nav-tabs nav-stacked"&gt;
                  &lt;li&gt;&lt;a ng-click="pob.pageidx=0"&gt;0&lt;/a&gt;&lt;/li&gt;
                  &lt;li&gt;&lt;a ng-click="pob.pageidx=1"&gt;1&lt;/a&gt;&lt;/li&gt;
                  &lt;li&gt;&lt;a ng-click="pob.pageidx=2"&gt;2&lt;/a&gt;&lt;/li&gt;
                  &lt;li&gt;&lt;a ng-click="pob.pageidx=3"&gt;3&lt;/a&gt;&lt;/li&gt;
              &lt;/ul&gt;
          &lt;/div&gt;
          &lt;div class="span11"&gt;
              &lt;ng-include src="index1.pages[pob.pageidx]"&gt;&lt;/ng-include&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>However, if I try to duplicate this using ng-repeat, it fails silently:</p>
  
  <pre><code>&lt;div ng-controller="LayoutCtrl"&gt;
      &lt;div class="row" ng-init="pob={pageidx:0}"&gt;
          &lt;div class="span1"&gt;
              &lt;ul class="nav nav-tabs nav-stacked"&gt;
                  &lt;li ng-repeat="n in index1.pages"&gt;&lt;a ng-click="pob.pageidx={{$index}}" &gt;{{$index}}&lt;/a&gt;&lt;/li&gt;
              &lt;/ul&gt;
          &lt;/div&gt;
          &lt;div class="span11"&gt;
              &lt;ng-include src="index1.pages[pob.pageidx]"&gt;&lt;/ng-include&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>Again, iterating through an array and just using the $index does not make a whole lot of sense in this example, but it's the underlying scope disconnect that is puzzling me.  Can anyone advise me?</p>