| 48 | imports: [FormField], |
| 49 | }) |
| 50 | export class LoginApp { |
| 51 | loginModel = signal<LoginData>({ |
| 52 | email: '', |
| 53 | password: '', |
| 54 | }); |
| 55 | |
| 56 | loginForm = form(this.loginModel, (schemaPath) => { |
| 57 | required(schemaPath.email, {message: 'Email is required'}); |
| 58 | email(schemaPath.email, {message: 'Enter a valid email address'}); |
| 59 | required(schemaPath.password, {message: 'Password is required'}); |
| 60 | }); |
| 61 | |
| 62 | onSubmit(event: Event) { |
| 63 | event.preventDefault(); |
| 64 | submit(this.loginForm, async () => { |
| 65 | // Perform login logic here |
| 66 | const credentials = this.loginModel(); |
| 67 | console.log('Logging in with:', credentials); |
| 68 | // e.g., await this.authService.login(credentials); |
| 69 | }); |
| 70 | } |
| 71 | } |
| 72 | |
| 73 | bootstrapApplication(LoginApp); |