ルーティングとパスパラメーターを使用して、角度のあるアプリケーションに取り組んでいます。ボタンをクリックすると、同じパス パラメータを持つ新しい URL にユーザーをリダイレクトする関数が呼び出されます。ブラウザーの URL は変更されますが、app-routing.module.ts で定義されている対応するコンポーネントは読み込まれません。ページを再度更新すると、正しいページがレンダリングされます。
アイデアは、生徒がハッシュ トークン (例: /student/33192c29aa8e449e94f3a1c4eef43ca8
) を使用して一意の URL を取得し、それによっていくつかのガイドラインが示されるというものです。その後クリックすると、同じトークンを持つ登録ページに転送されます (例: /student/registration/33192c29aa8e449e94f3a1c4eef43ca8
)
app-routing.module.ts
const routes: Routes = [
...
{ path: 'student/registration/:token', component: RegistrationsComponent },
{ path: 'student/:token', component: GuidelinesComponent },
...
];
ガイドライン.コンポーネント.html
forwardToRegistration(): void {
this.router.navigateByUrl('/student/registration/' + this.studentToken);
}
URL はブラウザーで正しく更新されていますが、RegistrationComponent はレンダリングされません。
ご協力ありがとうございました!