我正在尝试使用Materialize(http://materializecss.com/scrollspy.html)中的scrollspy来定位使用ng-repeat创建的每个div。

但是,在我看来,scrollspy类没有执行任何操作。 DOM无需重新滚动到页面的该部分,而是重新加载并指向页面的该部分。

另一个问题是使用href="/#community#sharingLove"会更改网站URL。无论如何,scrollspy是否可以工作而不添加URL?

<div class="full-height row" ng-controller="CommunityController">
    <div class="col l10 main-content">
        <div ng-repeat="principle in acmPrinciples" id ="{{principle.id}}" class="row full-width centering-text section scrollspy">
            <div class ="col-md-12">
                <h4>{{principle.title}}<h4>
            </div>
            <div class ="col-md-12 comm-description-container">
                <p class="paragraph-style larger-font-size">
                    {{principle.description}}
                 </p>
            </div>
            <div class ="col-md-12">
                <video class="responsive-video comm-video-height" controls>
                    <source ng-src="{{principle.videoURL}}" type="video/mp4">
                </video>
            </div>
        </div>
    </div>

    <div class="col l2 scroll-content">
        <div class="row">
            <div class="col hide-on-small-only m3 l2 scroll-items">
                <ul class="section table-of-contents">
                     <li><a href="#/community#experiencingGod">Experiencing God</a></li>
                     <li><a href="#/community#sharingLove">Sharing Love</a></li>
                     <li><a href="#/community#conntectingLives">Connecting Lives</a></li>
                     <li><a href="#/community#declaringTruth">Declaring Truth</a></li>
                </ul>
            </div>
        </div>
    </div>
</div>


我已链接包括jQuery,引导程序和实现。最后一件事:物化的其他功能对我有用,但不是滚动式的。我也做

$(document).ready(function(){
    $('.scrollspy').scrollSpy();
});

最佳答案

我认为,如果您从hrefs中删除#/ community,那么它应该起作用。 href应该包含块的ID,而不是多余的URL信息。例如尝试使用

<a href="#experiencingGod">Experiencing God</a>

关于javascript - 用于Materialize的Scrollspy无法使用Angularjs进行滚动,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/34999638/

10-12 16:59