<!DOCTYPE html>
<html>
        <head>
                <title>Wikitechy AngularJS Tutorials</title>
        </head>
                <script
                src="https://ajax.googleapis.com/ajax/libs/
                angularjs/1.5.6/angular.min.js"
>

                
</script>
        <body>
                <div ng-app="myApp" ng-controller="limitCtrl">
                <h2> Wikitechy limitTo filter in AngularJS </h2>
                    <ul>
                <h3> Display the first two items from a {{flowers}} array.</h3>
                                <li ng-repeat="x in flowers| limitTo : 2 ">
                                        {{ x }}
                                </li>
                <h3>Display a last two items from a {{flowers}} array.</h3>
                <li ng-repeat="x in flowers| limitTo : -2 ">
                                        {{ x }}
                                </li>
                <h3> Display the first two items from a "{{word}}" string.</h3>
                                <li ng-repeat="x in word| limitTo : 2 ">
                                        {{ x }}
                                </li>
                <h3> Display two items from a " {{ number }} " number, starting at position 1. </h3>
                                <li ng-repeat="x in number| limitTo : 2 : 1 ">
                                        {{ x }}
                                </li>
                        </ul>
                </div>
                <script>
                        var app = angular.module('myApp', []);
                        app.controller('limitCtrl', function($scope) {
                           $scope.flowers = ["Lily", "Rose", "Jasmine","Poppy"];
               $scope.word = "welcome";
               $scope.number = 231291171229;
                        });
                
</script>
        </body>
</html>












 


www.wikitechy.com © Copyright 2016. All Rights Reserved.