Add and edit recipes #3

Merged
clement.freville2 merged 2 commits from refs/pull/3/head into main 2024-06-17 14:10:13 +02:00
2 changed files with 7 additions and 5 deletions
Showing only changes of commit 60379fc2e1 - Show all commits

View File

@@ -5,5 +5,8 @@ import { withComponentInputBinding } from '@angular/router';
import { routes } from './app.routes'; import { routes } from './app.routes';
export const appConfig: ApplicationConfig = { export const appConfig: ApplicationConfig = {
providers: [provideZoneChangeDetection({ eventCoalescing: true }), provideRouter(routes, withComponentInputBinding())], providers: [
provideZoneChangeDetection({ eventCoalescing: true }),
provideRouter(routes, withComponentInputBinding()),
],
}; };

View File

@@ -1,8 +1,8 @@
import { Component, Input } from '@angular/core'; import { Component, Input } from '@angular/core';
import { FormBuilder, FormsModule, ReactiveFormsModule, Validators } from '@angular/forms'; import { FormBuilder, FormsModule, ReactiveFormsModule, Validators } from '@angular/forms';
import { Router } from '@angular/router';
import { Ingredient, IngredientEntry, Recipe } from '../../cookbook/type'; import { Ingredient, IngredientEntry, Recipe } from '../../cookbook/type';
import { RecipeService } from '../recipe.service'; import { RecipeService } from '../recipe.service';
import { Router } from '@angular/router';
@Component({ @Component({
selector: 'app-recipe-add', selector: 'app-recipe-add',
@@ -11,7 +11,6 @@ import { Router } from '@angular/router';
templateUrl: './recipe-add.component.html', templateUrl: './recipe-add.component.html',
}) })
export class RecipeAddComponent { export class RecipeAddComponent {
createForm = this.formBuilder.group({ createForm = this.formBuilder.group({
name: ['', Validators.maxLength(256)], name: ['', Validators.maxLength(256)],
description: ['', Validators.maxLength(512)], description: ['', Validators.maxLength(512)],
@@ -37,7 +36,7 @@ export class RecipeAddComponent {
this.createForm.patchValue({ this.createForm.patchValue({
name: recipe.name, name: recipe.name,
description: recipe.description, description: recipe.description,
}) });
} }
constructor(private formBuilder: FormBuilder, private recipes: RecipeService, private router: Router) {} constructor(private formBuilder: FormBuilder, private recipes: RecipeService, private router: Router) {}
@@ -73,6 +72,6 @@ export class RecipeAddComponent {
idIngredient: id, idIngredient: id,
idRecipe: -1, idRecipe: -1,
quantity: 1, quantity: 1,
}) });
} }
} }