I am trying to automatically scroll to bottom whenever there is a new message.
My code moves the scrollbar but it does not take it to exact bottom. Kindly help. Her
Thanks @MajoB
Here are my 2 cents including:
$timeout to make sure $digest cycle is finishedngScrollBottom.js:
angular.module('myApp').directive('ngScrollBottom', ['$timeout', function ($timeout) {
return {
scope: {
ngScrollBottom: "="
},
link: function ($scope, $element) {
$scope.$watchCollection('ngScrollBottom', function (newValue) {
if (newValue) {
$timeout(function(){
$element.scrollTop($element[0].scrollHeight);
}, 0);
}
});
}
}
}]);