router outlet导致页面上浮,如何解决?
router outlet cause the page to go up, how to solve this?
当用户单击特定行时,将调用 router-outlet 并在该行下方显示一个页面。问题是当用户点击该行时页面显示正常但是母版页上升(滚动顶部)..所以用户必须向下滚动才能看到(路由器出口)子页面数据。
如何防止滚动到顶部?
<table class="table table-bordered table-hover">
<div *ngFor="let values of domResponseData;let i = index" (window:scroll)="onScroll($event)">
<tr style="text-align: center" (click)="showDetails(values,'showdet',i)" [class.selected]="checkIndex==i">
<td style="text-align: left" width="30%">
<div>{{values.title}} {{values.firstName}} {{values.middleName}} {{values.lastName}}</div>
( {{values.registeredEmail}} )</td>
<td width="40%">
<div>Transaction-ID - {{values.transactionID}}</div>{{values.date | date:'full'}}</td>
<td width="500px">
<div>{{values.bookingstatus}}</div>Total Price :- ₹ {{values.totalPrice}}</td>
</tr>
<tr *ngIf="checkIndex==i" style="background-color: #e4e5e6; " id="jump">
<td colspan="3">
<router-outlet></router-outlet>
</td>
</tr>
</div>
<tr style="text-align: center" (click)="showMore()">Show More</tr>
</table>
好吧,找到了一个 hack...
setTimeout(function(){var y=window.scrollY+50;
window.scrollTo(0, y);
},150);
当用户单击特定行时,将调用 router-outlet 并在该行下方显示一个页面。问题是当用户点击该行时页面显示正常但是母版页上升(滚动顶部)..所以用户必须向下滚动才能看到(路由器出口)子页面数据。
如何防止滚动到顶部?
<table class="table table-bordered table-hover">
<div *ngFor="let values of domResponseData;let i = index" (window:scroll)="onScroll($event)">
<tr style="text-align: center" (click)="showDetails(values,'showdet',i)" [class.selected]="checkIndex==i">
<td style="text-align: left" width="30%">
<div>{{values.title}} {{values.firstName}} {{values.middleName}} {{values.lastName}}</div>
( {{values.registeredEmail}} )</td>
<td width="40%">
<div>Transaction-ID - {{values.transactionID}}</div>{{values.date | date:'full'}}</td>
<td width="500px">
<div>{{values.bookingstatus}}</div>Total Price :- ₹ {{values.totalPrice}}</td>
</tr>
<tr *ngIf="checkIndex==i" style="background-color: #e4e5e6; " id="jump">
<td colspan="3">
<router-outlet></router-outlet>
</td>
</tr>
</div>
<tr style="text-align: center" (click)="showMore()">Show More</tr>
</table>
好吧,找到了一个 hack...
setTimeout(function(){var y=window.scrollY+50;
window.scrollTo(0, y);
},150);