title: AngularJS $timeout sometimes works sometimes doesn't
body: <p>I'm experiencing some problems with AngularJS and $timeout.<br>
  I need to run some code, after the page is loaded. Http.get() loads items and ng-repeat displays them in table. Then I need to run the code to highlight row when I click it.</p>
  
  <p>I found a solution for that using $timeout.  </p>
  
  <pre><code>$timeout(function () {
      console.log('in timeout');
      $scope.highlightRows();
  });
  </code></pre>
  
  <p>this does work, but not every time. In the function I log number of rows in the table and sometimes I get 0, therefore the click handler is not registered and it highlighting doesnt work.  </p>
  
  <pre><code>$scope.highlightRows = function () {
      console.log($("#tripsTable").children("tbody").children("tr").length);
      $("#tripsTable").children("tbody").children("tr").children().click(function () {
          console.log('row click');
          $("#tripsTable").children("tbody").children("tr").removeClass("focusedRow");
          $(this.parentNode).addClass("focusedRow");
      });
  };
  </code></pre>
  
  <p>when try to simulate I have to refresh by Ctrl + F5.  </p>
  
  <p>console log:</p>
  
  <pre><code>in timeout tripsController.js:14
  0 
  </code></pre>
  
  <p>I couldn't find any solutions to this problem, any suggestions will be appreciated :)<br>
  Thanks<br>
  Mark  </p>
  
  <p><strong>EDIT:</strong>
  this is my HTML</p>
  
  <pre><code>&lt;table class="table table-bordered" id="tripsTable"&gt;@*table-hover*@
      &lt;thead&gt;
          ....
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr ng-repeat="trip in tripsVM.tripsList | orderBy: 'startDate'" ng-class="(trip.tripID == 0) ? 'newRow' : ''" class="row"&gt;
              ....
  </code></pre>