html - 在下拉列表中带有 anchor 滚动的 hrefs

标签 html css angularjs

我有一个像这样的下拉列表:

<div class="dropdown">
        <select>
            <option ng-repeat="i in sc.cl" value="{{i.deptname"}}><a ng-href="#{{i.id}}">{{i.deptname}}</a></option>
        </select>
</div>

基本上,下拉元素的名称在一个数组中,并且在 html 中有 id 为 i.id 的 div,如下所示:

<div class="right-bar">
                <section class="contact-block" ng-repeat="i in sc.cl" id="{{i.id}}">
                    <div class="description">{{i.deptname}}</div>
                    <div class="inner-block">
                        <div ng-repeat="j in i.cgs">
                            <img class="vertical-image" src="frame.png">
                            <img class="horizontal-image" src="mobileframe.png">
                        </div>
                    </div>
                </section>
            </div>

每当我单击下拉元素时,我都希望它滚动到特定部分。但是当我这样做时没有任何反应。为什么会这样?当我尝试在 chrome 中检查元素时,它甚至没有在 ng-repeat 下拉列表中显示标签。

最佳答案

你应该使用 Angular 的 $anchorScroll

请看一下这个类似的问题:How to handle anchor hash linking in AngularJS

关于html - 在下拉列表中带有 anchor 滚动的 hrefs,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44894320/

相关文章:

php - 更改 Woocommerce 产品页面上价格范围的字体大小

php - 如何将多个ID传递到jobCart页面?

html - 为什么我的网站右侧有额外的空白区域?

javascript - 如何使输入焦点像 dogpile.com?

angularjs - 如何处理 AngularJS 中的 $resource 服务错误

javascript - Angular JS - 如何调用模块的函数?

javascript - 元素相对于其父元素的坐标

javascript - 将图像映射与 ImageMapster jQuery 插件一起使用时,坐标会发生变化

html - Bootstrap : problems create web header

javascript - ion-radio 取消选中 ng-click 不起作用