AngularJS - 关注嵌套滚动中的对象

AngularJS - Focus on object in nested scroll

所以我正在尝试根据键输入获得嵌套的滚动焦点。为此,我使用了 ng-focus,但我似乎误解了它的用途。

这个 JSFiddle 展示了我到目前为止所做的事情。每当找到匹配项时,我都会将 ng-focus="x._focus" 设置为 true,并且在控制台日志中它会显示这正在发生。但是滚动不会移动到焦点 input 字段。怎么样?

嘿,我不太明白你想要什么,但是检查一下,让我知道这是否是你想要的 jsFiddle

function MyCtrl($scope) 
{
    $scope.list = []

    for(var i = 0; i < 500; i++){
        $scope.list.push({
        number: i,
        _focus: false
      })
    }

    $(document).keypress(function(e) 
    {
        for(var i = 0; i < $scope.list.length; i++)
        {
            if($scope.list[i].number === e.keyCode)
            {
                $scope.list[i]._focus = true
                console.info('found : ', $scope.list[i])
                $scope.$apply(); // Apply changes and change the false to true in dom

                $('#nestedScroll').animate(
                {
                    scrollTop: $("#nestedScroll span[scrollTo='true']").offset().top
                }, "slow");

                return
            } else {
                $scope.list[i]._focus = false
            }
        }
    });
}