title: AngularJS: How do I insert window.setTimeout into the scope function?
body: <pre><code>$scope.runTest = function() {
      var statesArray = ['Running', 'Complete', 'Rejected'];
      var rand = statesArray[Math.floor(Math.random() * statesArray.length)];
      item.state = 'Running';
      console.log(rand)
      window.setTimeout(function() {
          item.state = rand;
      }, 6000);
  };
  </code></pre>
  
  <p><code>item</code> state change to <code>Running</code> is successful, but after that state won't change to a random as stated in the <code>window.setTimeout</code> function.</p>
  
  <p>Where am I wrong here?</p>