I have this directive and if I scroll to top than the link function will be invoked - this works fine. In the link function I will splice 4 entries of the array - but this is no influence of the view - there are still the whole entries of the array shown. Therefore my question would be what I can do in order to remove the splices arrayentries from the browser view?
(function() {
'use strict';
angular
.module('myProject.common')
.directive('asScrollTop', asScrollTop);
function asScrollTop() {
var directive = {
restrict: 'A',
scope: { chatMessagesOfUser: '=chatMessagesOfUser' },
link: link
};
return directive;
////////////
function link(scope, element, attr) {
console.log(element);
element.on('scroll', function() {
if(element[0].scrollTop <= 0) {
scope.chatMessagesOfUser.splice(1, 4);
}
});
}
}
})();
The usage of the directive is like this:
<div data-as-scroll-top data-chat-messages-of-user="vm.chatMessagesOfUser">
</div>