title: Angularjs: filter ngRepeat when using ControllerAs
body: <p><a href="https://stackoverflow.com/questions/14796087/filter-results-6-through-10-of-100-with-ng-repeat-in-angularjs">This post</a> originally asked the question, and includes a popular answer, but I can't find a way of updating the code to work with ControllerAs.</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="false" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>var app = angular.module('myApp', []);
  
  app.filter('slice', function() {
    return function(arr, start, end) {
      return arr.slice(start, end);
    };
  });
  
  app.controller('MainController', function() {
    vm = this;
    vm.items = [];
    vm.start = 0;
    vm.end = 20;
    for (var i = 0; i &lt; 100; i++) vm.items.push(i);
    return vm;
  });</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"&gt;&lt;/script&gt;
  
  &lt;div ng-app="myApp"&gt;
    &lt;div ng-controller='MainController as main'&gt;
      Start: &lt;input ng-model="main.start"&gt; End: &lt;input ng-model="main.end"&gt;
      &lt;ul&gt;
        &lt;li ng-repeat="item in items | slice:main.start:main.end"&gt;{{item}}&lt;/li&gt;
      &lt;/ul&gt;
    &lt;/div&gt;
  &lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>