<!DOCTYPE html>
<html>

<head>
  <script data-require="angular.js@1.1.5" data-semver="1.1.5" src="http://code.angularjs.org/1.1.5/angular.min.js"></script>
  <link rel="stylesheet" href="style.css" />
  <script src="script.js"></script>
</head>

<body ng-app="">
  <div ng-controller="MainController">

    Using the Angular Filter - LimitTo in View Templates

    <p>In Angular Filters are used to modify data in some way.</p>

    <p>Angular definition for LimitTo filter: Creates a new array or string containing only a specified number of elements. The elements are taken from either the beginning or the end of the source array or string, as specified by the value and sign (positive
      or negative) of limit. Reference: <a href="http://docs.angularjs.org/api/ng/filter/limitTo">link</a>
    </p>

    <h5>Show first two items in a list with limitTo</h5>
    <code>
         ng-repeat="item in items | limitTo:2">{{item}}
  </code>

    <ul>
      <li ng-repeat="item in items | limitTo:2">{{item}}</li>
    </ul>

    <h5>Show last two items in a list with limitTo -2</h5>

    <code>
         ng-repeat="item in items | limitTo:-2">{{item}}
  </code>


    <ul>
      <li ng-repeat="item in items | limitTo:-2">{{item}}</li>
    </ul>

    <h5>Show the last 3 characters of string with limitTo</h5>


    <code>
        "The brown fox" | limitTo: -3
  </code>

    <p>{{"The brown fox" | limitTo: -3}}</p>



    <h5>Show the first 140 characters of string with limitTo</h5>


    <code>
        "The brown fox" | limitTo: 140
  </code>

    <p>{{"Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.
      It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with
      desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum." | limitTo: 140}}</p>

  </div>

  <p>We can see that by using limitTo with a positive value we can show the first N values of an array, or string. By using a negative value we can see the last values of an array or string.</p>

</body>

</html>
// Code goes here

var MainController = function($scope){
  $scope.selectedId = null;
   $scope.items = [1,2,3,4];
};
/* Styles go here */