feat: add hotel form and test components with routing
This commit is contained in:
parent
21eb309acc
commit
0a0378e1c4
12 changed files with 155 additions and 5 deletions
0
src/app/test/test.component.css
Normal file
0
src/app/test/test.component.css
Normal file
10
src/app/test/test.component.html
Normal file
10
src/app/test/test.component.html
Normal 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>
|
23
src/app/test/test.component.spec.ts
Normal file
23
src/app/test/test.component.spec.ts
Normal 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();
|
||||
});
|
||||
});
|
34
src/app/test/test.component.ts
Normal file
34
src/app/test/test.component.ts
Normal 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);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue