]> gitweb.hhaalo.de Git - speisekarten-editor.git/commitdiff
add: remove one food and fix new food refs
authorBastian Dehn <hhaalo@arcor.de>
Mon, 6 Jun 2022 12:36:09 +0000 (14:36 +0200)
committerBastian Dehn <hhaalo@arcor.de>
Mon, 6 Jun 2022 12:36:09 +0000 (14:36 +0200)
src/app/app.component.html
src/app/app.component.ts

index 5f965b83ed6997ee42e151f7f4361722bc969a3e..2323d820be87939ff37f3b4327610b045a2d9e82 100644 (file)
        <h1>{{title.Title}}</h1>
        <div *ngFor="let subtitle of title.Subtitles">
                <h2>{{subtitle.Subtitle}}</h2>
-               <div *ngFor="let food of subtitle.Foods">
+               <div *ngFor="let food of subtitle.Foods; let i = index">
                        <div class="food">{{food.Food}}</div>
                        <div class="sideDish">{{food.sideDish}}</div>
                        <div class="price">{{food.price}}</div>
+                       <button type="button"
+                               (click)="removeFood(subtitle, i)">Löschen</button>
                </div>
        </div>
 </div>
index 9eeab51a4013b58c030a72fd21b0db2277e2b412..0432c23e74088e5080e08851719dafa5ffe568b8 100644 (file)
@@ -84,6 +84,12 @@ export class AppComponent
        {
                let lastSubtitle = this.getLastSubtitle();
                lastSubtitle.Foods.push(this.food);
+               this.food = { Food: "", sideDish: "", price: "" };
+       }
+
+       public removeFood(subtitle: ISubtitle, foodindex: number): void
+       {
+               subtitle.Foods.splice(foodindex, 1);
        }
 
        private getLastTitle(): ITitle