title: Angular JS: ng-click scope set doesn't work in ng-if
body: <p>Today, I have seen a bug in angularjs:</p>
  
  <p>When you try to set a scope value directly in a ng-click, it doesn't work when your ng-click is in a ng-if which test the same scope value -> <a href="http://jsfiddle.net/9j2TL/26/" rel="noreferrer">http://jsfiddle.net/9j2TL/26/</a></p>
  
  <pre><code>angular.module('test', [])
  .controller('testCtrl', function($scope) {
      $scope.step = 1;
  
      $scope.setStep = function(step) {
           $scope.step = step;  
      };
  });
  
  &lt;div ng-app="test"&gt;
  &lt;div ng-controller="testCtrl"&gt;
      &lt;ul class="timeline"&gt;
          &lt;li&gt;
              &lt;div class="block-submit"&gt;
                  &lt;button class="btn btn-primary btn-lg" ng-click="step = 2"&gt;Without ngif block&lt;/button&gt;
              &lt;/div&gt;
          &lt;/li&gt;
  
          &lt;li ng-if="step &gt; 1"&gt;
              &lt;div class="block-submit"&gt;
                  &lt;button class="btn btn-primary btn-lg" ng-click="step = 3"&gt;with ngif block&lt;/button&gt;
              &lt;/div&gt;
          &lt;/li&gt;
  
          &lt;li ng-if="step &gt; 1"&gt;
              &lt;div class="block-submit"&gt;
                  &lt;button class="btn btn-primary btn-lg" ng-click="setStep(3)"&gt;With ngif block and scope function&lt;/button&gt;
              &lt;/div&gt;
          &lt;/li&gt;
      &lt;/ul&gt;
      &lt;p&gt;
          step value : {{ step }}
      &lt;/p&gt;
  &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>To solve it, you should create a scope function...</p>
  
  <p>If somebody have a explication for this problem, I would be happy to understand it !</p>
  
  <p>thx :)</p>