$scope.runTest = function() {
var statesArray = ['Active', 'Completed', 'Rejected'];
var randState = statesArray[Math.floor(Math.random() * statesArray.length)];
item.state = 'Active';
console.log(randState);
window.setTimeout(function() {
item.state = randState;
}, 6000);
};
The item
's state is successfully changed to Active
, but it doesn't change to a random state as intended in the window.setTimeout
function.
What am I missing here?