I have tried applying ngInfiniteScroll on angular.js component.
I know that needs to use ng-repeat
, acutally I don't know how to apply this.
In my case, data is build as HTML document for repeating.
Each of $ctrl.htmlViews
data like this.
<li ...> ... </li> <li ...> ... </li> ... <li ...> ... </li>
I want to append these documents in <ul>
below.
<div class="scroll" id="antTalkList" view-type="total
<ul class="user_list list ng-scope"
infinite-scroll='$ctrl.loadMore()' infinite-scroll-distance='1'>
<div ng-repeat="item in $ctrl.htmlViews"><!-- I don't wanna use this -->
<ng-bind-html ng-bind-html="item"> </ng-bind-html>
</div>
</ul>
</div>
Here is my code snippet of Controller.
.component('antList', {
templateUrl : 'templates/ant-list.html'
, controller : function AntListController($http, $attrs, $sce){
var self = this;
this.htmlViews = [];
this.loading = false;
this.loadMore = function(){
$http({
method : "GET",
url : 'ant/list?pageCount=20&startIndex='
+ $('#antTalkList .user_list li').size()
+ '§ionId=' +$attrs.talkType
}).then(function mySucces(response) {
self.htmlViews.push($sce.trustAsHtml(response.data));
});
}
}
})
Result of $http
ajax request, is already built in HTML code like below.
<li>item 1</li>
<li>item 2</li>
<li>item 3</li>
<li>item 4</li>
...
I thought a tag having ng-repat
is repated, so I wrote code like above code. However, I don't want to use <div ng-repeat= ....></div>
. Because that case, result page will be like this.
<ul ...>
<div>
<li ...>
...
</div>
<div>
<li ...>
...
</div>
</ul>
I think this looks awful. How can I repeat whithout additional tag(s) like div
?
One more problem.
I declared infinite-scroll='$ctrl.loadMore()' infinite-scroll-distance='1'
but angular.js doesn't calls loadMore()
function after loaded(It means, just 1 requests when it's initialized, and no more calls the function).