Every 2 seconds, a JavaScript function is being called that updates a specific div on the view when a certain condition is met.
<div id="ball_{{ballIndex}}">{{ball}}</div>
This is controlled by the ng controller.
var myCounter = 0;
var interval = $interval(function () {
if (myCounter <= 35) {
myCounter ++;
DoSomething();
} else {
//
}
}, 1500);
function setCurrentBallEffect() {
$('#ball_' + myCounter).addClass('magictime puffIn');
}
function DoSomething() {
if (myCounter == 0) {
$scope.ballIndex = 1;
} else {
$scope.ballIndex = myCounter;
}
}
Only the first div in each iteration is being applied with the class "magictime puffIn". When I manually set div IDs on the view like
<div id="ball_1">1</div>
<div id="ball_2">2</div>
, the applied CSS class works on each div. What could be the issue?
Update: Tried using
<div ng-attr-id="{{ 'ball_' + ballIndex }}"> </div>
But the problem persists.