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) {
-
- 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