我有一张有物品的桌子。单击一行时,详细项信息在表旁边的固定div中显示upp。
表旁边的div连接到url中的一个参数。因此,当我单击一个项时,url将url更改为/project/:itemID
问题是,当单击一行时,表“跳转”到另一个位置。卷轴改变位置。我想让它留在原来的地方。
这是我的控制器,它更改url:
$scope.goToProduct = function(id){
var path = $location.path();
var splitUrl = path.split('/');
var project = splitUrl[1];
console.log(project);
$location.path(project + '/' + id);
}这是我的看法:
<input type="text" class="form-control" placeholder="Search">
<div class="table-responsive">
<table class="table table-hover">
<thead>
<tr>
<th>Code</th>
<th>Namn</th>
<th>Manufactor</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="product in products | filter:query" ng-click="goToProduct(product.pr_id)">
<td>{{product.pr_usercode}}</td>
<td>{{product.pr_title}}</td>
<td>{{product.pr_producer}}</td>
<td>{{product.pr_description}}</td>
</tr>
</tbody>
</table>
</div>知道怎么解决这个问题吗?
发布于 2014-02-10 16:39:57
解决了。Ui-路由器有一个方便的指令。只需添加autoscroll="false“即可。博士:https://github.com/angular-ui/ui-router/wiki/Quick-Reference#wiki-autoscroll
https://stackoverflow.com/questions/21659558
复制相似问题