Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 选择inside ng table,在ng table中重新加载数据时,页面返回顶部_Javascript_Angularjs - Fatal编程技术网

Javascript 选择inside ng table,在ng table中重新加载数据时,页面返回顶部

Javascript 选择inside ng table,在ng table中重新加载数据时,页面返回顶部,javascript,angularjs,Javascript,Angularjs,我们使用ng表在页面上呈现一些数据。在表中,ng repeater逐行渲染对象数组中的值。其中一列是选择框,其值取自控制器内声明和填充的数组 这是数组的声明: $scope.CharacteristicsToChange = []; 这是方法中某个位置的数组的填充: if ($scope.ItemProfile.ProductionDateRegistration != 'No') $scope.CharacteristicsToChange.push({ Name: 'Product

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

这是数组的声明:

$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 if
ng show
的实例?在没有看到更多代码的情况下,当您重新加载数据时,听起来您可能实际上正在删除/隐藏DOM上的元素,然后重新创建它(从而使其滚动回顶部)

我有一些ng show,但其中的表达式始终是相同的,因此,如果加载页面时显示一个项目,则在页面打开时会始终显示该项。代码每10秒填充刷新数据的代码是什么样子?