You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
bromista-nisqa-receta/src/app/recipe-form/recipe-form.component.html

32 lines
1.2 KiB

<h2>New Recipe</h2>
<form [formGroup]="recipeForm" (ngSubmit)="onSubmit()">
<label for="name">Name:</label>
<input id="name" formControlName="name">
<br>
<label for="description">Description:</label>
<textarea id="description" formControlName="description"></textarea>
<br>
<label for="image">Image URL:</label>
<input id="image" type="file" formControlName="image" (change)="onFileChange($event)">
<br>
<div formArrayName="ingredients">
<h3>Ingredients</h3>
<button type="button" (click)="addIngredient()">Add Ingredient</button>
<div *ngFor="let ingredient of ingredients.controls; let i = index" [formGroupName]="i">
<label for="ingredientName">Ingredient:</label>
<select id="ingredientName" formControlName="name">
<option *ngFor="let option of ingredientsOptions" [value]="option" [selected]="option === defaultOption">
{{option}}</option>
</select>
<label for="ingredientQuantity">Quantity:</label>
<input id="ingredientQuantity" formControlName="qty">
<button type="button" (click)="removeIngredient(i)">Remove</button>
<br>
</div>
</div>
<button type="submit">Add Recipe</button>
</form>