Add RecipeService

This commit is contained in:
2024-06-14 14:38:41 +02:00
parent 9baca1c78c
commit 4b5b05f396
12 changed files with 52 additions and 22 deletions

19
src/app/recipe.service.ts Normal file
View File

@@ -0,0 +1,19 @@
import { Injectable } from '@angular/core';
import { Recipe } from '../cookbook/type';
@Injectable({
providedIn: 'root',
})
export class RecipeService {
#recipes: Recipe[] = [];
constructor() {}
getAll(): Promise<Recipe[]> {
return Promise.resolve(this.#recipes);
}
get(id: number): Recipe | null {
return this.#recipes.find((recipe) => recipe.id === id) || null;
}
}