我从数据库中获取新闻的数量,但例如,当我最大限度地限制新闻,使我总共收到24条新闻时,则标签“下载更多新闻”?
一切都像它应该的那样播放,但它必须离开,这样一个人就不能“下载更多新闻”按钮。
只是为了表明你不能下载更多的新闻
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;
});
})
发布于 2016-07-28 21:18:05
尝试ng-show表达式,如下所示:
<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 < Newslist.length">
Download more news</button>
</div>
</div>
https://stackoverflow.com/questions/38637360
复制相似问题