我有一个像这样的下拉列表:
<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/