gpt4 book ai didi

javascript - 选择内部ng表,当重新加载ng表中的数据时,页面返回顶部

转载 作者:行者123 更新时间:2023-12-03 01:19:19 25 4
gpt4 key购买 nike

我们正在使用 ng 表在页面上呈现一些数据。在表格内,ng-repeater 从对象数组中逐行渲染值。其中一列是一个选择框,其值取自在 Controller 内声明和填充的数组。

这是数组的声明:

$scope.CharacteristicsToChange = [];

这是方法中某处的数组的总体:

if ($scope.ItemProfile.ProductionDateRegistration != 'No')
$scope.CharacteristicsToChange.push({ Name: 'Production date' });

if ($scope.ItemProfile.BestBeforeDateRegistration != 'No')
$scope.CharacteristicsToChange.push({ Name: 'Best before date' });

选择框是:

<select class="form-control" id="ddlCharacteristics" ng-options="characteristic.Name as characteristic.Name for characteristic in CharacteristicsToChange" name="Characteristic" ng-model="inventory.SelectedCharacteristic" required>
<option value="" class="select-placeholder"> Select characteristic type</option>
</select>

我们的问题是,当重新加载 ng 表的数据(每 10 秒)并且页面滚动到底部时,页面会返回到顶部。

我认为问题在于我们为 select ( $scope.CharacteristicsToChange ) 获取值的数组,因为当我删除该数组的填充部分时,重新加载问题不再发生。

最佳答案

页面上是否有任何 ng-ifng-show 实例?如果没有看到更多代码,听起来您实际上可能在重新加载数据时删除/隐藏 DOM 上的元素,然后重新创建它(从而使其滚动回顶部)

关于javascript - 选择内部ng表,当重新加载ng表中的数据时,页面返回顶部,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51835125/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com