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 ? ? ?