很抱歉这个奇怪的标题,但找不到更好的解释。
我有spring webapp,在一个页面上有类似社交网络的内容。在里面
angularjs
控制器我有一个数组,我在其中存储帖子以显示在视图中。因此
ng-repeat
这是我的代码的缩短版本。
html:
<div class="main" ng-model="activities" ng-repeat="activity in activities">
<div class="helper" >
<center>
<p><img alt="{{activity.user.username}}" ng-src="pictures/{{activity.user.picture}}" height="50px"> </img> </p>
<p><a href="#" >{{activity.user.username}} </a></p>
<br />
<p class="date">{{activity.activity.datum}} </p>
<p>
{{activity.activity.tempo}}/km {{activity.activity.distance}} km</p>
<br />
</center>
</div>
<br/><br/>
</div>
<center><a href="#" ng-click="loadMore()">Load more</a></center>
</div>
$scope.loadMore = function(){
$scope.getActivities(3 , $scope.currentPage+1 , $scope.loggedInUser.username).then(function(response){
$scope.currentPage++;
for(var i = 0; i<response.length; i++){
$scope.activities.push(response[i]);
}
});
}
每一次
$scope.activities