例如,我來自當前網址http://localhost:4200/#/transactions/overview/5?tab=2
,然后導航到http://localhost:4200/#/deals/detail/
當我重繪 交易/詳細資訊頁面時,我想回傳上一個 url,例如http://localhost:4200/#/transactions/overview/5?tab=2.
我們如何解決這個角度問題?感謝您的幫助和想法。
#用于導航到交易/詳細資訊頁面的代碼
editDeal(deal:any){
let dealType = '';
const state = {
data: {
transaction: this.transaction,
},
}
this.gotoDealDetails(state);
}
gotoDealDetails(state:any){
this.route.navigateByUrl(`deals/detail/`, {state: state});
}
#detail 詳情頁組件
export class DealDetailsComponent implements OnInit {
dealDetails = null;
leaseDetails = null;
currentRentSchedule = [];
isInEditMode = false;
fiscalYear = null;
pmrType = null;
partnerType: any;
constructor(
private _route: Router,
private _dealService: DealService,
private dialog: MatDialog,
private _notificationService: NotificationService) {
this.urlData = this._route.getCurrentNavigation().extras.state.data
}
ngOnInit(): void {
}
ngAfterViewInit() {
}
}
uj5u.com熱心網友回復:
當您重繪 頁面時,獲取要在重繪 頁面上呼叫的任何事件,在該事件中,您可以在要執行重繪 的組件(此處稱為 AnyComponent)中呼叫 back() 方法,如下所示:
component.ts 檔案示例
import { Location } from '@angular/common'
@Component({...})
export class AnyComponent {
constructor(private location: Location) {}
back(): void {
this.location.back()
}
}
有關更多詳細資訊,請參閱此鏈接:https : //nils-mehlhorn.de/posts/angular-navigate-back-previous-page
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/370259.html
