离子滚动到元素

dav*_*s.1 5 javascript ionic-framework ionic

我有一个:

<span id="quote-{{quote.id}}" ng-repeat="quote in quotes">{{quote.text}}</span>
Run Code Online (Sandbox Code Playgroud)

我正在尝试使用索引滚动到滚动条的任何部分:

$scope.jumpToQuote = function (quote) {
  $scope.quoteSelected = quote;
  var quotePosition = $ionicPosition.position(angular.element(document.getElementById('quote-'+quote)));
  $ionicScrollDelegate.$getByHandle('quotes-box').scrollTo(quotePosition.left, quotePosition.top, true);
}
Run Code Online (Sandbox Code Playgroud)

但是,quotePosition.top的值总是等于10,这是最高的偏移量<ion-scroll>.

Mud*_*jaz 4

据我所知,您需要替换document.getElementById('quote-'+quote)document.getElementById('quote-'+quote.id),您正在连接整个quote对象而不是它的id