JSFiddle - React, Tailwind, and code Playground
HTML
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<div ng-app="testApp" ng-controller="myC">
<p ng-repeat="t in ta" on-finish-render="test()">{{t}}</p>
</div>
JavaScript
var module = angular.module('testApp', [])
.directive('onFinishRender', function ($timeout) {
return {
restrict: 'A',
link: function (scope, element, attr) {
if (scope.$last === true) {
scope.$evalAsync(attr.onFinishRender);
}
}
}
});
function myC($scope, $interval) {
$scope.ta = [1, 2, 3, 4, 5, 6];
$scope.test = function() {
console.log('test');
}
$scope.$watch('ta', function (newVal, oldValue) {
if(oldValue.length > 0)
{
var i = 0; // do something
console.log("removed or added");
// can call test function from here
$scope.test();
}
}, true);
$interval(function(){
var number = Math.floor((Math.random() * 100) + 1);
if(number%2==1) {
$scope.ta.pop();
console.log('popped')
} else {
$scope.ta.push(number)
console.log('pushed')
}
}, 3000);
}