title: Can't get the filtered items from my filtered list inside a modal
body: <p>I have a page where I can open a modal window when selecting a certain "instruction"<br>
  When that modal window is loaded, I have inside of it a text input for searching, an ordered list to list all of the "instructions" (except the one I selected), a dropdown list to select the amount of instructions I want to see per page, 2 buttons for next and previous page as well as text showing the current page and how many page there is.</p>
  
  <p>This is what it looks like (the Manual dropdown list does nothing for now)
  <img src="https://i.stack.imgur.com/tg4q2.png" alt="Looks like this"></p>
  
  <p>So far, I get all my instructions just right, my filter work, the result per page works, the next and previous button change the page... but it seems like my numberOfPages function isn't working.</p>
  
  <p>This is the modal HTML page:</p>
  
  <pre><code>&lt;div&gt;
          Search: &lt;input type="text" ng-model="search.Description"/&gt; Manual: 
          &lt;select ng-options="manual.Description for manual in manuals"&gt;
  
          &lt;/select&gt;
      &lt;/div&gt;
      &lt;br /&gt;
      &lt;div class="table clearfix" style="max-width: 800px; max-height: 300px; overflow: scroll;"&gt;
          &lt;ol class="table-body clearfix"&gt;
              &lt;li class="table-row clearfix" ng-repeat="item in ( filteredItems = ( instructions | filter:search:strict)) | startFrom:currentPage*showLimit | limitTo:showLimit" ng-include="'js/manuals/manuals-item-instruction-attachment-showInstruction.html'"&gt;&lt;/li&gt;
          &lt;/ol&gt;
  
      &lt;/div&gt;
      &lt;div&gt;
          &lt;button ng-disabled="currentPage == 0" ng-click="currentPage=currentPage-1"&gt;Previous&lt;/button&gt;
              Page: {{currentPage + 1}}/{{numberOfPages()}}
          &lt;button ng-disabled="currentPage &gt;= numberOfPages() - 1" ng-click="currentPage=currentPage + 1"&gt;Next&lt;/button&gt;
          Results per page:
          &lt;select ng-model="showLimit"&gt;
              &lt;option value="10"&gt;10&lt;/option&gt;
              &lt;option value="20"&gt;20&lt;/option&gt;
              &lt;option value="50"&gt;50&lt;/option&gt;
              &lt;option value="100"&gt;100&lt;/option&gt;
          &lt;/select&gt;
      &lt;/div&gt;
  </code></pre>
  
  <p>This is the function where my modal is created and opened</p>
  
  <pre><code>openreference: function (item) {
      var modalInstance = $modal.open({
          templateUrl: 'js/manuals/manuals-item-instruction-attachment.html',
          controller: ModalInstanceCtrl,
          resolve: {
              instruction: function () {
                  return item;
              }
          }
      });
      modalInstance.result.then(function (selectedItem) {
          $scope.selected = selectedItem;
      },
      function () {
          $log.info('Modal dismissed at: ' + new Date());
      });
  }
  </code></pre>
  
  <p>And this is my modal controller</p>
  
  <pre><code>var ModalInstanceCtrl = function ($scope, $modalInstance, instruction) {
      $scope.showLimit = 10;
      $scope.currentPage = 0;
      $scope.numberOfPages = function () {
          if ($scope.currentPage + 1 &gt; Math.ceil($scope.filteredItems.length / $scope.showLimit)) {
              $scope.currentPage = 0;
          }
          return Math.ceil($scope.filteredItems.length / $scope.showLimit);
      }
      $http({ method: 'GET', url: '../api/Instructions/GetAllOtherInstructions', params: { 'instructionId': instruction.Id} }).success(function (result) {
          $scope.instructions = result;
      });
      $scope.cancel = function () {
          $modalInstance.dismiss('cancel');
      };
  };
  </code></pre>
  
  <p>After debugging, my filteredItems in the numberOfPages function was always undefined no matter where I tried to place the numberOfPages function in my code.</p>
  
  <p>Why are my filteredItems from the ng-repeat always undefined? I have the same thing in a non-modal page and it's working perfectly fine.</p>