Ng - if not working, ng-show works

I have html where I should AngularJSonly show the template when I get to the bottom of the page (I implemented infinite scrolling).

The first page comes from the server. Therefore, I have to put ng-iffor this first page, because the user can have a bookmark with the address "address / page = 5", and the html template for the first page from the server does not have to be in page

Now I have a URL specific to the page from the server.

ng-ifdoesn't work, the page is blank, but if I use ng-show, everything works fine.

HTML

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

        <div ng-show="server_page()"> 
        //here the first page template

Js

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;
}

If I make a comment

//$scope.item_gallery = new ItemGallery();

ng-if is working fine, the page is displayed correctly.

The page is displayed when I use: ng-if + comment, ng-show.

NOTE.

ng-if="true" , , ng-if="server_page()" ng-show.

ng-if ? ? ?

+4
2

, .

:

'rel' null.

, , var ItemGallery = function(), href ( ajax). href <div> .

, href , .

..

window.onload = function () {
                this.nextPageQueryString = document.getElementById("nextPage").rel;

                this.next_href = this.domain_url + this.nextPageQueryString;
            };

: , . ng-if rel href, . Angular rel, .

ng-if , html.

ng-if.

+1

ng-if

ng, :

SCOPE, ,

ng-if='showStuff' //here my scope is model **INCORRECT**
ng-if='someObject.showStuff' // ** CORRECT **

ng-, ng-if , .

, ng-show , .

$scope.item_gallery = new ItemGallery();

$scope.someObject.item_gallery = new ItemGallery();

.

+4

All Articles