1

I get the number of news from the database, but for example when I max limit of news such that I receive 24 news in total, then the tag "download more news"ยจ

Everything plays as it should, but it must just get away such that one can not "download more news" button.

Just to show you can not download more news

Index.Html

<div class="col-md-12" ng-app="NewsLoad" ng-controller="ListNews">
        <ul class="team-list sort-destination">
            <li class="col-md-4 col-sm-6 col-xs-12 isotope-item leadership" ng-repeat="New in Newslist | limitTo: totalDisplayed" style="max-height:380px; float:left;">
                @*html here*@
            </li>
        </ul>

        <div class="form-group col-md-12" style="margin-top:23px;">
            <button class="btn-block btn btn-info" ng-click="change()">Download more news</button>
        </div>
    </div>

Load.js

var app = angular.module('NewsLoad', []);
app.controller('ListNews', function ($scope, $http) {

    $scope.totalDisplayed = 9;

    $scope.change = function () {
        $scope.totalDisplayed += 6;
    }

    var url = "/Nyheder/all";

    $http.get(url).success( function(response) {
        $scope.Newslist = response; 
    });

})
kukkuz
  • 41,512
  • 6
  • 59
  • 95
  • when there is no more to display you want to hide the "Download more news" button? โ€“ kukkuz Jul 28 '16 at 13:11
  • yes. it is, I would like, realize that I should just throw `ng-show=""` on div by button. But that's just it stip on which I lack. โ€“ J. Willumsen Jul 28 '16 at 13:13

1 Answers1

1

Try the ng-show expression as below:

<div class="col-md-12" ng-app="NewsLoad" ng-controller="ListNews">
        <ul class="team-list sort-destination">
            <li class="col-md-4 col-sm-6 col-xs-12 isotope-item leadership" ng-repeat="New in Newslist | limitTo: totalDisplayed" style="max-height:380px; float:left;">
                @*html here*@
            </li>
        </ul>

        <div class="form-group col-md-12" style="margin-top:23px;">
            <button class="btn-block btn btn-info" ng-click="change()" 
               ng-show="totalDisplayed &lt; Newslist.length">
               Download more news</button>
        </div>
    </div>
kukkuz
  • 41,512
  • 6
  • 59
  • 95