switch to one-way-binding in form
This commit is contained in:
parent
125af5a206
commit
0ab106d021
@ -1,24 +1,24 @@
|
||||
<div id="firstBlock">
|
||||
<form (ngSubmit)="addAccountEntry()">
|
||||
<form (ngSubmit)="addAccountEntry(userForm)" #userForm="ngForm">
|
||||
<mat-form-field appearance="outline" id="addEntryfield">
|
||||
<mat-label>Datum</mat-label>
|
||||
<input matInput name="createdAt" [(ngModel)]="newAccountEntry.created_at" [matDatepicker]="createdAtPicker"/>
|
||||
<input matInput ngModel name="createdAt" [matDatepicker]="createdAtPicker"/>
|
||||
<mat-datepicker-toggle matSuffix [for]="createdAtPicker"></mat-datepicker-toggle>
|
||||
<mat-datepicker #createdAtPicker></mat-datepicker>
|
||||
</mat-form-field>
|
||||
<mat-form-field appearance="outline">
|
||||
<mat-label>Kategorie</mat-label>
|
||||
<mat-select [(ngModel)]="newAccountEntry.account_entry_category" name="category" [disabled]="shallBeRentPayment">
|
||||
<mat-select ngModel name="category" [disabled]="shallBeRentPayment">
|
||||
<mat-option *ngFor="let p of accountEntryCategories" [value]="p.id">{{p.description}}</mat-option>
|
||||
</mat-select>
|
||||
</mat-form-field>
|
||||
<mat-form-field appearance="outline">
|
||||
<mat-label>Betrag (€)</mat-label>
|
||||
<input matInput type="number" name="amount" [(ngModel)]="newAccountEntry.amount"/>
|
||||
<input matInput type="number" name="amount" ngModel/>
|
||||
</mat-form-field>
|
||||
<mat-form-field appearance="outline">
|
||||
<mat-label>Beschreibung</mat-label>
|
||||
<input matInput name="description" [(ngModel)]="newAccountEntry.description"/>
|
||||
<input matInput name="description" ngModel/>
|
||||
</mat-form-field>
|
||||
<button #addAccountEntryButton type="submit" mat-raised-button color="primary">Buchung speichern</button>
|
||||
</form>
|
||||
|
@ -39,7 +39,7 @@ export class AccountComponent implements OnInit {
|
||||
accountEntryCategoriesMap: Map<number, AccountEntryCategory>
|
||||
accountEntryCategoriesInverseMap: Map<string, AccountEntryCategory>
|
||||
|
||||
newAccountEntry: AccountEntry = NULL_AccountEntry
|
||||
// newAccountEntry: AccountEntry = NULL_AccountEntry
|
||||
|
||||
|
||||
constructor(
|
||||
@ -87,7 +87,10 @@ export class AccountComponent implements OnInit {
|
||||
}
|
||||
}
|
||||
|
||||
async addAccountEntry(): Promise<void> {
|
||||
async addAccountEntry(userForm: any): Promise<void> {
|
||||
this.messageService.add(`${JSON.stringify(userForm.value, undefined, 4)}`)
|
||||
userForm.reset()
|
||||
/*
|
||||
try {
|
||||
this.addAccountEntryButton.disabled = true
|
||||
this.newAccountEntry.account = this.account.id
|
||||
@ -101,6 +104,7 @@ export class AccountComponent implements OnInit {
|
||||
} finally {
|
||||
this.addAccountEntryButton.disabled = false
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
async getAccountEntryCategories(): Promise<void> {
|
||||
|
Loading…
x
Reference in New Issue
Block a user