1

示例.html

<tbody>
   <tr ng-repeat="item in items" im-move-hash>
     <td id="{{ item.id }}"></td>
   </tr>
</tbody>

示例.js

angular.module('myApp', [])
.directive('imMoveHash', function() {
  return function(scope, element, attrs) {
    if (scope.$last){
     $location.hash(Session.getHashParams());
     $anchorScroll();
    }
  };
});

我已经将哈希参数设置为 Session。前任)。#1234

我预计 $anchorScroll() 会起作用,并且 html 中的锚链接会被触发,但它失败了。

因为我认为这个失败可能发生在 html 中每个 'td' 的 'id' 属性在 $anchorScroll 被触发之前没有正确设置,我想得到关于每个 id 属性集完成的事件,然后使 $anchorScroll 发生。

有谁知道如何获得完成 html 属性设置的事件?还是有其他原因导致锚滚动在上面的 html 中不起作用?

提前致谢。

4

0 回答 0