JSFiddle - React, Tailwind, and code Playground

by Daan De Smedt

HTML

<script src="https://cdnjs.cloudflare.com/ajax/libs/angular-translate/2.15.1/angular-translate.min.js"></script>
<!-- application container -->
<div ng-app="app" ng-controller="demoController">

  <div ng-repeat="item in dataItems" my-repeat-end-listener>
    loop item : {{item}}
    <div ng-if="$last" ng-init="callFunctionInit()">last</div>
  </div>

</div>

JavaScript

angular
.module('app', [])

.controller('demoController', function($scope){
	$scope.dataItems = [
  	{'id' : 1, 'name' : 'test1'},
    {'id' : 1, 'name' : 'test1'},
    {'id' : 1, 'name' : 'test1'}
  ];
  
  $scope.callFunction = function(){
    console.log('function invoked');
  }
  
  $scope.callFunctionInit = function(){
    console.log('function called on view');
  }
  
})

.directive('myRepeatEndListener', function() {
  return function(scope, element, attrs) {
    if (scope.$last){
    	console.log('last item');
      scope.callFunction();
    }else{
    	console.log('not last item');
    }
  };
})