Я использую Angular 6, тему ngx-admin с аутентификацией. Я хочу передать идентификатор токена в URL-адресе для сброса пароля и получить этот идентификатор в форме сброса пароля, чтобы я мог передать его на внутренний сервер. Ниже мой файл app-routing.module.ts:
{
path: 'auth',
component: NgxAuthComponent,
children: [
{
path: '',
component: NgxLoginComponent,
},
{
path: 'request-password',
component: NgxRequestPasswordComponent,
},
{
path: 'reset-password/:token',//here i need token
component: NgxResetPasswordComponent,
},
А ниже находится файл NgxResetPasswordComponent:
constructor(protected service: NbAuthService,
@Inject(NB_AUTH_OPTIONS) protected config = {},
protected router: Router) {
this.redirectDelay = this.getConfigValue('forms.resetPassword.redirectDelay');
this.showMessages = this.getConfigValue('forms.resetPassword.showMessages');
this.provider = this.getConfigValue('forms.resetPassword.provider');
console.info(this.router.url);//output: /auth/reset-password/dsadasdasfaf
}
Мне нужно получить «dsadasdasfaf» по этому URL-адресу и передать его в форму.





Сначала импортируйте ActivateRoute и инициализируйте его
constructor(private activatedRoute: ActivatedRoute) {}
this.activatedRoute.params.subscribe((params: Params) => {
let token = params['token'];
console.info(token);
});