parent
9baca1c78c
commit
4b5b05f396
@ -1,10 +1,10 @@
|
|||||||
import { Routes } from '@angular/router';
|
import { Routes } from '@angular/router';
|
||||||
import {RecipesComponent} from './recipes/recipes.component'
|
import { RecipeAddComponent } from './recipe-add/recipe-add.component';
|
||||||
import {RecipeComponent} from './recipe/recipe.component'
|
import { RecipeComponent } from './recipe/recipe.component';
|
||||||
import {RecipeAddComponent} from './recipe-add/recipe-add.component'
|
import { RecipesComponent } from './recipes/recipes.component';
|
||||||
|
|
||||||
export const routes: Routes = [
|
export const routes: Routes = [
|
||||||
{ path: 'recipes', component: RecipesComponent},
|
{ path: 'recipes', component: RecipesComponent },
|
||||||
{ path: 'recipe/add', component: RecipeAddComponent},
|
{ path: 'recipe/add', component: RecipeAddComponent },
|
||||||
{ path: 'recipe/:id', component: RecipeComponent}
|
{ path: 'recipe/:id', component: RecipeComponent },
|
||||||
];
|
];
|
||||||
|
@ -0,0 +1,16 @@
|
|||||||
|
import { TestBed } from '@angular/core/testing';
|
||||||
|
|
||||||
|
import { RecipeService } from './recipe.service';
|
||||||
|
|
||||||
|
describe('RecipeService', () => {
|
||||||
|
let service: RecipeService;
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
TestBed.configureTestingModule({});
|
||||||
|
service = TestBed.inject(RecipeService);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should be created', () => {
|
||||||
|
expect(service).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in new issue