1
In this plunk有一個帶兩個按鈕顯示/隱藏的桌子。如果您將表格滾動到底線,然後單擊隱藏,然後再次單擊顯示,表格仍將顯示底線。我需要任何時候點擊顯示按鈕,表格應該在頂部顯示第一行。這是可行的嗎?當桌子變得可見時在頂部顯示第一排
HMTL
<div style="width:300px;height:80px;border:1px solid gray;overflow-y:auto"
ng-show="show">
<table>
<tr ng-repeat="item in items">
<td>{{item.col}}</td>
</tr>
</table>
</div>
<br>
<button ng-click="show=false">Hide</button>
<button ng-click="show=true">Show</button>
的Javascript
var app = angular.module('app', []);
app.controller('ctl', function($scope) {
$scope.items = [ {col:"aaa"}, {col:"bbb"} , {col:"ccc"},
{col:"aaa2"}, {col:"bbb2"} , {col:"ccc2"},
{col:"aaa2"}, {col:"bbb2"} , {col:"ccc2"} ];
$scope.show = true;
});