TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
tri_inn
NA
1.2k
233.5k
AngularJS: infinite scroll with ng-repeater
Jun 13 2017 10:49 AM
i am new in angular. so hopping many site to read nice article on angular code example. so today i visited a site http://www.dotnetawesome.com/2016/03/infinite-scroll-for-facebook-like-pagination-angularjs.html
which come with a example like how to create infinite scroll with angularJS.
here i will post some question which is not clear to me. so please answer and guide about those syntax and code in the article because i need to understand.
1) there is one function called NextPage() which the function name has been assign with directive name like this way
<div infinityscroll=
"NextPage()"
style=
"height:400px; overflow:auto;"
> ?
$scope.NextPage = function () {
if
($scope.CurrentPage < $scope.TotalPage) {
$scope.CurrentPage += 1;
GetEmployeeData($scope.CurrentPage);
}
}
tell me what does it mean to assign function name with directive name
<div infinityscroll="NextPage()" style="height:400px; overflow:auto;"> ?
does it mean when directive will load then the NextPage() function will be called or it has different meaning ?
2) see the directive code first
app.directive(
'infinityscroll'
, function () {
return
{
restrict:
'A'
,
link: function (scope, element, attrs) {
element.bind(
'scroll'
, function () {
if
((element[0].scrollTop + element[0].offsetHeight) == element[0].scrollHeight) {
//scroll reach to end
scope.$apply(attrs.infinityscroll)
}
});
}
}
});
what is the meaning of this line
scope.$apply(attrs.infinityscroll)
hence i am new so i am fumbling when reading article on angular js v1+. so please answer my 2 questions in details to guide me. thanks
Reply
Answers (
1
)
AngularJS: service and factory is singleton ?
What is the usage and advantages of q$ in angularjs