Javascript 角锚链不工作

Javascript 角锚链不工作,javascript,jquery,angularjs,anchor,anchor-scroll,Javascript,Jquery,Angularjs,Anchor,Anchor Scroll,sample.html <tbody> <tr ng-repeat="item in items" im-move-hash> <td id="{{ item.id }}"></td> </tr> </tbody> 我已经将哈希参数设置为会话。ex)#1234 我希望$anchorScroll()可以工作,html中的锚链接会被触发,但失败了 因为我认为这个失败可能是在$anchorScroll被激发

sample.html

<tbody>
   <tr ng-repeat="item in items" im-move-hash>
     <td id="{{ item.id }}"></td>
   </tr>
</tbody>
我已经将哈希参数设置为会话。ex)#1234

我希望$anchorScroll()可以工作,html中的锚链接会被触发,但失败了

因为我认为这个失败可能是在$anchorScroll被激发之前,html中每个'td'的'id'属性没有正确设置,所以我想获取每个id属性集完成的事件,然后使$anchorScroll发生

有人知道如何获取html属性设置完成事件吗?或者有没有其他原因导致锚定滚动无法在上面的html中工作


提前感谢。

尝试包装
$timeout
或将元素参数传递给
$anchorScroll
尝试包装
$timeout
或将元素参数传递给
$anchorScroll
angular.module('myApp', [])
.directive('imMoveHash', function() {
  return function(scope, element, attrs) {
    if (scope.$last){
     $location.hash(Session.getHashParams());
     $anchorScroll();
    }
  };
});