title: angularjs show last 5 items in ng-repeat list
body: <p>I have a list which logs previous names that I have chosen as shown below.  What I want is for the list to always only show the last 5 results, however what I have at the moment is showing the first 5 in order of time with latest first.  How can this be achieved?</p>
  
  <p><a href="http://jsfiddle.net/sfqo2fn3/1/" rel="noreferrer">http://jsfiddle.net/sfqo2fn3/1/</a></p>
  
  <pre><code>    &lt;div ng-controller="MyCtrl"&gt;
          &lt;input type="text" ng-model="updatedname" /&gt;
          &lt;input type="button" value="Change name" ng-click="changeName(updatedname)"/&gt;
          &lt;br/&gt;
            Hello, {{name}}!
      &lt;ul&gt;
          &lt;li ng-repeat="name in nameLog | limitTo:5 | orderBy:'time':true"&gt;{{name.value}} - {{name.time}}&lt;/li&gt;
      &lt;/ul&gt;    
      &lt;/div&gt;
  
      var myApp = angular.module('myApp',[]);
      myApp.factory('UserService', function() {
                  var _nameLog = [];
                  var userService = {};
                  userService.name = "John";
                  userService.ChangeName = function (value) {
                      userService.name = value;
                  };
                  userService.logName  = function (value) {
                      _nameLog.push ({
                          "value":value,
                          "time" :Date.now()
                      });
                  };
                  userService.getNameLog = function(){ return _nameLog; }
          return userService;
      });
  
      function MyCtrl($scope, UserService) {
          $scope.name = UserService.name;
          $scope.updatedname="";
          $scope.changeName=function(data){
              $scope.updateServiceName(data);
          }
          $scope.updateServiceName = function(name){
              UserService.ChangeName(name);
              UserService.logName(name);
              $scope.name = UserService.name;
              $scope.nameLog = UserService.getNameLog();
          }
      }
  </code></pre>