Im trying to use scrolly directive for my div. when user scrol down and end of div come I want to call a function. it gives me undefined on Scope.$apply function ? please any one help . Thankx in advance here is my html code
<div id="container" style="
position:absolute;
top: 60px;
width: 100%;
left:0px;height:91%;overflow-y:scroll;" scrolly="showMore()" >
here is app and controller
var app = angular.module('smac',[]);
app.controller('asd',function ($http,$scope) {
$scope.showMore = function(){
alert('div finished');
}
});
and the directive is
app.directive('scrolly', function () {
return {
restrict: 'A',
link: function (scope, element, attrs) {
var raw = element[0];
console.log('loading directive');
element.bind('scroll', function () {
console.log('in scroll');
console.log(raw.scrollTop + raw.offsetHeight >= raw.scrollHeight)
if (raw.scrollTop + raw.offsetHeight >= raw.scrollHeight) {
scope.$apply(attrs.scrolly)
console.log(scope.$apply(attrs.scrolly)); // this is undefined
}
});
}
};
});