Angularjs Get first and last value of list-item (li)

Today, We want to share with you Angularjs Get first and last value of list-item (li).In this post we will show you Angular ngFor, ng-template and the compiler, hear for Add a class to last 3 list items in AngularJS we will give you demo and example for implement.In this post, we will learn about Show only first and last child as result inside `ng-repeat` with an example.

Angularjs Get first and last value of list-item (li)

There are the Following The simple About angularjs show last 5 items in ng-repeat list Full Information With Example and source code.

Read Also:  how to calculate percentage discount using calculator?

As I will cover this Post with live Working example to develop how to get last value of array in angularjs, so the Angular NgFor: Everything you need to know is used for this example is following below.

How to get the last record in an array in AngularJS?

{{ObjectsArr[ObjectsArr.length - 1]}}

var app = angular.module('app', ['ui.bootstrap']);
app.controller('productCtrl', function ($scope) {
	$scope.data = [1,2,3]
});

<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.2.14/angular.min.js"></script>
  <script src="//cdnjs.cloudflare.com/ajax/libs/angular-ui-bootstrap/0.12.0/ui-bootstrap-tpls.min.js"></script>
  <meta charset="utf-8">
  <title>Example</title>
</head>
<body >
  <div ng-app="app">
    <div ng-controller="productCtrl">
<ul>
      <li ng-repeat="item in product" ng-if="$last">{{item}}</li>
</ul>
    </div>
    </div>
</body>
</html>

angularjs show last 5 items in ng-repeat list

using limitTo: -5

<div ng-repeat="product in products | limitTo: -1">
    {{product.name}}
</div>

<li ng-repeat="p in product | limitTo:-5 | orderBy:'time':true">...</li>

ng-repeat show only last element

Read Also:  Check if element Exists on the Page using jQuery

<div ng-repeat="n in [data[data.length-1]] track by $index">
    <span>{{n}}</span>
</div>

Web Programming Tutorials Example with Demo

Read :

Summary

You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about angular 6 get last element of array.
I would like to have feedback on my infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.