title: Why is ng-class based ng-animate transition not working?
body: <p>This is a heavily simplified demo of <code>ng-class</code> animation using transition  that I'm trying to achieve.</p>
  
  <p>I'm trying to create a simple fade in animation when an item is selected.</p>
  
  <p>Selecting an item will add a <code>selected</code> class on it using <code>ng-class</code> directive. I'm trying to add a transition to it following the <a href="https://docs.angularjs.org/guide/animations#class-and-ngclass-animation-hooks" rel="nofollow">documentation</a> with the animation hook classes added by <code>ng-animate</code>.</p>
  
  <p>Below is the code I have so far. It sets the <code>opacity</code> to <code>0</code> along with the transition property, and when the <code>.selected-add-active</code> class is added it is supposed to transition to <code>opacity</code> 1. But it does not work. </p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="false" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>angular.module('demo', ['ngAnimate'])
    .controller('demoCtrl', function($scope) {
      $scope.selected = false;
      $scope.selectToggle = function() {
        $scope.selected = !$scope.selected;
      };
    });</code></pre>
  <pre class="snippet-code-css lang-css prettyprint-override"><code>.item {
    width: 50px;
    height: 50px;
    background: grey;
  }
  .item.selected {
    background-color: dodgerblue;
  }
  .item.selected.selected-add {
    transition: opacity 3s;
    opacity: 0;
  }
  .item.selected.selected-add.selected-add-active {
    opacity: 1;
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.7/angular.js"&gt;&lt;/script&gt;
  &lt;script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.7/angular-animate.js"&gt;&lt;/script&gt;
  &lt;div ng-app="demo" ng-controller="demoCtrl"&gt;
    &lt;div class="item" ng-class="{selected:selected}"&gt;&lt;/div&gt;
    &lt;br&gt;
    &lt;br&gt;
    &lt;button ng-click="selectToggle();"&gt;
      {{selected? 'Unselect' : 'Select'}}
    &lt;/button&gt;
  &lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>Why isn't my code working?</p>