]> gitweb.hhaalo.de Git - speisekarten-editor.git/commitdiff
add: subtitle and show them
authorBastian Dehn <hhaalo@arcor.de>
Mon, 6 Jun 2022 11:22:05 +0000 (13:22 +0200)
committerBastian Dehn <hhaalo@arcor.de>
Mon, 6 Jun 2022 11:22:05 +0000 (13:22 +0200)
src/app/app.component.html
src/app/app.component.ts

index 147432fd3c45825a76a52cfff07a7c53303350b0..5de8a5b0744b9bbbd00773e55351781a73893b59 100644 (file)
@@ -25,7 +25,8 @@
        <input [(ngModel)]="subtitle" name="subtitle" type="text" />
        <button class="button"
                type="button"
-               id="addSubtitle">Hinzufügen</button>
+               id="addSubtitle"
+               (click)="addSubtitle()">Hinzufügen</button>
 </form>
 
 <form #formFood="ngForm" *ngIf="formFoodVisible" class="form">
@@ -42,4 +43,7 @@
 
 <div *ngFor="let title of foodcard.Titles">
        <h1>{{title.Title}}</h1>
+       <div *ngFor="let subtitle of title.Subtitles">
+               <h2>{{subtitle.Subtitle}}</h2>
+       </div>
 </div>
index 063ca36659fc3945f0dab18065ed3a52dc57cc46..a4bf9a92b4cefb6589ecfaec3dc29b488b7fd1e5 100644 (file)
@@ -47,4 +47,14 @@ export class AppComponent
                });
                this.formTitleVisible = false;
        }
+
+       public addSubtitle(): void
+       {
+               let lastIndex = this.foodcard.Titles.length - 1;
+               this.foodcard.Titles[lastIndex].Subtitles.push({
+                       Subtitle: this.subtitle,
+                       Foods: []
+               });
+               this.formSubtitleVisible = false;
+       }
 }