Add RecipeService
This commit is contained in:
19
src/app/recipe.service.ts
Normal file
19
src/app/recipe.service.ts
Normal 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;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user