diff --git a/src/main/resources/generator/client/angular/security/jwt/src/main/webapp/app/login/login.component.ts.mustache b/src/main/resources/generator/client/angular/security/jwt/src/main/webapp/app/login/login.component.ts.mustache index d0c77d55b6d..836d4414d33 100644 --- a/src/main/resources/generator/client/angular/security/jwt/src/main/webapp/app/login/login.component.ts.mustache +++ b/src/main/resources/generator/client/angular/security/jwt/src/main/webapp/app/login/login.component.ts.mustache @@ -1,5 +1,5 @@ import { CommonModule } from '@angular/common'; -import { Component, inject, OnDestroy, OnInit } from '@angular/core'; +import { Component, DestroyRef, inject, OnInit } from '@angular/core'; import { FormBuilder, FormGroup, ReactiveFormsModule, Validators } from '@angular/forms'; import { Subject, takeUntil } from 'rxjs'; import { AccountService } from '../auth/account.service'; @@ -17,7 +17,7 @@ import { MatCardModule } from '@angular/material/card'; standalone: true, styleUrls: ['./login.component.css'], }) -export default class LoginComponent implements OnInit, OnDestroy { +export default class LoginComponent implements OnInit { private readonly destroy$ = new Subject(); account: Account | null = null; @@ -33,6 +33,11 @@ export default class LoginComponent implements OnInit, OnDestroy { username: ['', [Validators.required]], password: ['', [Validators.required]], }); + const destroyRef = inject(DestroyRef); + destroyRef.onDestroy(() => { + this.destroy$.next(); + this.destroy$.complete(); + }); } ngOnInit(): void { @@ -42,11 +47,6 @@ export default class LoginComponent implements OnInit, OnDestroy { .subscribe(account => (this.account = account)); } - ngOnDestroy(): void { - this.destroy$.next(); - this.destroy$.complete(); - } - login(): void { this.loginService .login({