0
我的角2項目只有1頁,所以我根本沒有使用路由概念。但是着陸頁可以有一個URL參數或沒有它。那麼,如何在未使用路由時捕獲URL參數,或者是否需要爲此需求使用路由。根據URL參數的可用性,我需要在頁面中執行額外的操作。角2項目中的着陸頁url參數
RouterModule.forRoot
我的角2項目只有1頁,所以我根本沒有使用路由概念。但是着陸頁可以有一個URL參數或沒有它。那麼,如何在未使用路由時捕獲URL參數,或者是否需要爲此需求使用路由。根據URL參數的可用性,我需要在頁面中執行額外的操作。角2項目中的着陸頁url參數
RouterModule.forRoot
例如,在你的路由:
path: '', pathMatch: 'full', redirectTo: 'login',
{ path: 'login', component: InlogComponent }
在你的其他組件必須功能註銷()
import { Router } from '@angular/router';
constructor(private router: Router){}
private logout() {
this.router.navigateByUrl('/login');
是您發佈的答案 –
正確的問題@RahulSingh如果這是正確的答案,我不知道,但這是基礎知識。 – Swoox