Christian Schmitt Christian Schmitt - 1 year ago 127
AngularJS Question

AngularJS Scroll to Bottom after Scope Change/resource Change

Currently I tried to make it with $anchorScroll

But I don't know where to place the

<a id="bottom">

currently my view is a
and i have a
on a
Then I
for scope changes and apply them to the


<tr ng-repeat="document in documents.items">

Code in my Controller:

$scope.$watchCollection('search', function (newData, oldData) {
if (newData != null) {
$scope.documents = Document.query(newData)

Now I tried to put the
after the
but nothing ever happend.

Also a Bonus question:
Should I place a paging function to a
or should i make it with
<div ng-click="nextPage()">

Answer Source

Ok I found out that i just need a setTimeout due to the fact, that i first change the scope and then try to scroll to bottom, but the new scope isn't rendered yet!

EDIT: To Scroll after content get's rendered via ng-repeat: do setTimeout(() => { /* Your scroll stuff here */ }, 0); to

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download