范围更改/资源更改后 AngularJS 滚动到底部

标签 angularjs

目前我试图用 $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/

相关文章:

angularjs - Angular js 与 spring mvc

angularjs - ng-options 禁用选项但仍将其显示为选中

html - AngularJS html 模板的代码覆盖率

javascript - 在 AngularJS 中动态注册过滤器?

angularjs - 仅使用 Ionic Framework 或 Onsen UI 作为托管 Web 应用程序有什么缺点

javascript - 用于组件之间通信的 AngularJS 方法?

javascript - Angularjs 上 Controller 的启用/禁用按钮

javascript - Angular Bootstrap时间选择器不绑定(bind)时间

javascript - 在其他非 Angular 应用程序的 iframe 中进行 Protractor 测试?

javascript - NG-repeat 不是从示波器中读取数据吗?