ng-if not working, ng-show works
<p>I have an html where I must show <code>AngularJS</code> template only when I reach the bottom of the page (I've implemented infinite scrolling).</p>

<p>The first page comes from the server. So I've to put an <code>ng-if</code> for that first page, because the user could have a bookmark with "address/page=5", and the html template for the first page from the server doesn't have to be in the page.</p>

<p>Now I have the url "address", specific for the page from the server.</p>

<p><code>ng-if</code> doesn't work, the page is empty, but if I use <code>ng-show</code> it all works fine.</p>

<p><strong>HTML</strong></p>

<pre><code>&lt;div ng-app="MyApp" ng-controller="MyCtrl"&gt;
    &lt;div id="itemsGrid" ng-controller="aCtrl" infinite-scroll='item_gallery.nextPage()' infinite-scroll-distance='1' infinite-scroll-disabled=''&gt; 

        &lt;div ng-show="server_page()"&gt; 
        //here the first page template
</code></pre>

<p><strong>JS</strong></p>

<pre><code>myApp.controller('MyCtrl', function($scope, ItemGallery) {
    $scope.item_gallery = new ItemGallery();
    ...
}

myApp.factory('ItemGallery', function($http) {
    var ItemGallery = function() {
    ...
        ItemGallery.prototype.nextPage = function() {
        ...
        }
    return ItemGallery;
}
</code></pre>

<p>If I do comment</p>

<pre><code>//$scope.item_gallery = new ItemGallery();
</code></pre>

<p>ng-if works fine, the page is correctly showed.</p>

<p>The page is showed when I use: ng-if + line commented, ng-show.</p>

<p><strong>NOTE:</strong> </p>

<p><code>ng-if="true"</code> doesn't work, it's not a problem of the function used, <code>ng-if="server_page()"</code>
I don't want to use ng-show.</p>

<p>Why <code>ng-if</code> doesn't work? What's the problem with that line? How can I make it working?</p>