I come from a JQuery background and don't know if this is possible or not in AngularJS.
I am working on a project using Ionic framework & AngularJS
I am trying to capture the "on scrolling" event using angular.
Currently I use the following HTML to create a list of 20 items and the following code outputs the "test" string on the console log on page load. But when I scroll up or down the list the event doesn't seem to fire again.
I've been researching but I can't seem to come across a way to get the "on scroll event" after the page has been loaded. At least directive doesn't get call when the user is interacting with the list, so I think this is the wrong approach.
How can I capture that event in angular? Is it possible?
HTML
<ion-content>
<div class="list" >
<div class="item" ng-repeat="item in data.items" when-scrolled="loadMore()" >Item {{item}}</div>
</div>
</ion-content>
JS
angular.module('starter.controllers', ["ionic"])
.controller('AppCtrl', function($scope,$ionicScrollDelegate) {
$scope.myTitle = 'Template';
$scope.data = {
items : [],
title : ''
};
for(var i = 0; i < 20; i++) {
$scope.data.items.push(i);
}
})
.directive('whenScrolled', function () {
return function(scope, element, attrs) {
console.log("test");
};
});
onscrollis an HTML event you can use to call any JavaScript, so why does<div onscroll="loadmore()">not work?