目前我试图用 $anchorScroll 来实现它
但是不知道放在哪里
<a id="bottom">
目前我的观点是
<table>
我有一个 ng-repeat
在 <tr>
.然后我
$watch
范围更改并将其应用于 ng-repeat
.html:
<tr ng-repeat="document in documents.items">
<td>{{document.subject}}</td>
<td>{{document.course}}</td>
<td>{{document.bundle}}</td>
<td>{{document.lesson}}</td>
<td>{{document.category}}</td>
<td>{{document.name}}</td>
</tr>
我的 Controller 中的代码:
$scope.$watchCollection('search', function (newData, oldData) {
if (newData != null) {
$scope.documents = Document.query(newData)
console.log(newData);
}
现在我试着把
$location.hash
和 $anchorScroll
后 $scope.documents
但什么也没发生。还有一个奖金问题:
我应该将分页功能放在
directive
上吗?或者我应该用 <div ng-click="nextPage()">
最佳答案
好的,我发现我只需要一个 setTimeout
由于我首先更改范围,然后尝试滚动到底部,但新范围尚未呈现!
编辑 :
在通过 ng-repeat
呈现内容后滚动:做 setTimeout(() => { /* Your scroll stuff here */ }, 0);
到
关于范围更改/资源更改后 AngularJS 滚动到底部,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20358303/