【问题标题】:Angular bootstrap scrollspy doesn't work with dynamic image contentAngular bootstrap scrollspy 不适用于动态图像内容
【发布时间】:2014-01-17 00:46:28
【问题描述】:

我遵循了这个答案并提出了一个例子:

How to implement a scrollspy in angular.js the right way?

我的目的是使用模板填充动态内容,其中有图像:

http://plnkr.co/edit/OKrzSr

**HTML代码区别:((

    <div ng-repeat="item in items">
      <h4 id="{{ item.id }}">{{ item.id }}</h4>
      <p ng-repeat="img in [1,2,3,4,5]"><img ng-src="{{ item.src }}"></p>
    </div>

Javascript代码区别:

angular.module('scrollSpyPlunk')
  .controller('scrollSpyCtrl', function ($scope, $anchorScroll)
{
$scope.items = [{
  "id": "section1",
  "src": "http://placehold.it/400x400"
},{
  "id": "section2",
  "src": "http://placehold.it/400x400"
},{
  "id": "section3",
  "src": "http://placehold.it/400x400"
}]
});

scrollspy 功能似乎无法按预期工作。当我向下滚动时,它太早地激活了菜单。我认为它将图像仅视为一行文本。我不确定。

任何帮助解决这个问题?

【问题讨论】:

    标签: javascript angularjs twitter-bootstrap angular-ui-bootstrap scrollspy


    【解决方案1】:

    我在这里写了自己的 Scrollspy 指令https://github.com/quanghoc/angular-bootstrap-scrollspy

    关键是添加这个事件

    $rootScope.$on('scrollspy.refresh', function() {
      refresh(attrs);
    });
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-06-12
      • 1970-01-01
      • 2012-08-10
      • 2020-07-16
      相关资源
      最近更新 更多