Besucher auf Struct umgeschrieben

This commit is contained in:
Husky
2022-01-04 19:30:34 +01:00
parent d0bc77271e
commit 8c814daf48
5 changed files with 36 additions and 13 deletions

View File

@@ -0,0 +1,9 @@
.example-radio-group {
display: flex;
flex-direction: column;
margin: 15px 0;
}
.example-radio-button {
margin: 5px;
}

View File

@@ -16,11 +16,14 @@
</table>
<input placeholder="Ihre Name..." [(ngModel)]="BesucherName">
<input placeholder="Eventuell eine Nachricht" [(ngModel)]="BesucherMessage">
<input placeholder="Eventuell eine Nachricht" [(ngModel)]="BesucherMessage"><br />
<label id="zusage-radio-button-group-label">Kommen Sie</label>
<mat-radio-group>
<mat-radio-button value="1">Ja</mat-radio-button>
<mat-radio-button value="0">Nein</mat-radio-button>
<mat-radio-group
aria-labelledby="zusage-radio-button-group-label"
class="example-radio-group"
[(ngModel)]="BesucherKommtRadio"
>
<mat-radio-button class="example-radio-button" *ngFor="let entscheidung of kommt" [value]="entscheidung">{{entscheidung}}</mat-radio-button>
</mat-radio-group>
<button class="btn btn-primary" (click)="addBesucher()">Abschicken</button>

View File

@@ -5,6 +5,7 @@ import { filter } from 'rxjs';
import { BesucherService } from '../besucher.service';
import { Besucher } from 'src/besucher';
@Component({
selector: 'app-besucher',
templateUrl: './besucher.component.html',
@@ -17,8 +18,12 @@ export class BesucherComponent implements OnInit {
kommendeBesuchers: Besucher[] = [];
BesucherName: string = "";
BesucherMessage: string = "";
BesucherKommt: boolean = false;
BesucherKommtRadio: string = "";
kommt: string[] = ['Ja','Nein'];
constructor(private besucherService: BesucherService) { }
ngOnInit(): void {
@@ -48,13 +53,19 @@ export class BesucherComponent implements OnInit {
name : this.BesucherName,
message : this.BesucherMessage,
id: '',
come : this.BesucherKommt
come : this.convertBesucherkommtStringToBoolean(this.BesucherKommtRadio)
};
console.log(newBesucher.come);
this.besucherService.addBesucher(newBesucher).subscribe(() => {
this.getAll();
this.BesucherMessage = '';
})
}
convertBesucherkommtStringToBoolean(input: string) : boolean {
return input == this.kommt[0]
}
}