title: Order of execution of on-click, ng-class & $digest cycles
body: <p>I've got a ui-view that swaps between 3 different templates. One of the requirements though, is that the templates slide in and out from the left or the right side depending on what link is clicked within each template.</p>
  
  <p>Now the problem that I'm facing, is something along the following lines:</p>
  
  <pre><code>&lt;div ui-view class='list' ng-class="{'slide-left':myCon.direction=='left','slide-right:myCon.direction=='right'}"&gt;
      &lt;a ng-click="myCon.setDirectionAndGoToState('right')"&gt;slide Right&lt;/a&gt;
      &lt;a ng-click="myCon.setDirectionAndGoToState('left')"&gt;slide Left&lt;/a&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>What I'm seeing in the DOM through Chrome's developer tools, is that when the  click happens on the "slide Right" link, both the ui-view elements (both the leaving and the newly generate entering ones) get the correct <code>.slide-right</code> classes.
  And then the leaving ui-view element disappears, and the active ui-view element has the class of <code>.slide-right</code>.
  Now if I were to then click the "Slide Left" link, then the leaving ui-view has the <code>.slide-left</code> class applied, but the newly generated entering ui-view still has the <code>.slide-right</code> class applied... Presumably from when it was duplicated... Which therefore implies that the duplication from the <code>$state.go</code> executed in the function triggered by the ng-click event, is actually happening before the ng-class. Or at least that's the implication that I'm getting....</p>
  
  <p>Does anybody have any idea if that's what is actually going on... If it is, is there a way for me to change the order so that the ng-class is being evaluated after the new direction is set within the controller, and for the $state.go to only perform its duplication <em>after</em>?</p>
  
  <p>Thanks!</p>