I am getting data from a server and then depending on the data I am changing a filter for ng-repeat
. After I change the filter I am trying to scroll to a new element that will be visible after the ng-repeat
filter has been updated.
The problem is that
I can change the filter dynamically but it takes around 5 seconds for angular to detect the change and update the ng-repeat
. My scroll code runs immediately after the ng-repeat
filter has changed, since it hasn't been updated, I get an error saying
the element does not exist.
My Question is
How can I make the ng-repeat
update as soon as the filter is changed and then call my scroll when the ng-repeat
has finished filtering?
Here is my current code
//Set ng-repeat filter
orderTypeFilter = 0;
//Scroll to element that will be visible after ng-repeat finishes updating
var topPos = document.getElementById('cardOrder0').offsetTop;
document.getElementById('main-md-content').scrollTop = topPos - 10;