Q:

Why does this not cause an infinite loop?

I have this piece of code. Logically this should go into an infinite render loop. But it remains stable and the output is that a and b, both, get printed together.
<div ng-if='hello'>
    <span ng-init='hello=false'>a</span>
</div>
<div ng-if='!hello'>
    <span ng-init='hello=true'>b</span>
</div>

This is not part of anything I am working on. It just popped up in my head and I could not find an answer to this anywhere.
Edit
I understand that in my above example as @dfsq pointed out, ng-if creates a new scope. So I changed the code a bit in this example. So here both ng-ifs should refer to the same object. Why is it not going into a loop here?
HTML
<div ng-app='app'>
  <div ng-controller='appCtrl'>
    <div ng-if='object.hello'>
      <span ng-init='object.hello=false'>a</span>
    </div>
    <div ng-if='!object.hello'>
      <span ng-init='object.hello=true'>b</span>
    </div>
  </div>
</div>

JS
(function() {
  var app = angular.module("app", []);

  app.controller("appCtrl", [
    "$scope",
    function($scope) {
      $scope.object = {};
      $scope.object.hello = true;
    }
  ]);
})();

A:

Logically this should go into an infinite render loop.

No, it should not. ngIf directive creates new child scope, and because of that ngInit modifies (creates) independent flag, which doesn't affect the one used in ngIf (parent scope hello).

