feat: add hotel form and test components with routing

This commit is contained in:
Jan K9f 2024-11-19 11:32:02 +01:00
parent 21eb309acc
commit 0a0378e1c4
Signed by: jank
GPG key ID: B267751B8AE29EFE
12 changed files with 155 additions and 5 deletions

View file

View file

@ -0,0 +1,10 @@
<p>test works!</p>
<form [formGroup]="loginForm">
<label for="username">Username</label>
<input type="text" id="username" autocomplete="username" formControlName="username">
<label for="password">Password</label>
<input type="password" id="password" formControlName="password">
<button (click)="submit()" type="submit">Login</button>
<button type="reset" (click)="reset()">Reset</button>
</form>

View file

@ -0,0 +1,23 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { TestComponent } from './test.component';
describe('TestComponent', () => {
let component: TestComponent;
let fixture: ComponentFixture<TestComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [TestComponent]
})
.compileComponents();
fixture = TestBed.createComponent(TestComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View file

@ -0,0 +1,34 @@
import { Component } from '@angular/core';
import { FormControl, FormGroup, ReactiveFormsModule } from '@angular/forms';
@Component({
selector: 'app-test',
standalone: true,
imports: [ReactiveFormsModule],
templateUrl: './test.component.html',
styleUrl: './test.component.css'
})
export class TestComponent {
public loginForm!: FormGroup;
public ngOnInit(): void {
this.loginForm = this.setUpLoginForm();
console.log(this.loginForm);
}
setUpLoginForm(): FormGroup {
return new FormGroup({
username: new FormControl("Jan"),
password: new FormControl('')
});
}
reset(): void {
this.loginForm = this.setUpLoginForm();
}
submit(): void {
console.log(this.loginForm.value);
}
}