Use ingredients from API, recipes from localStorage
This commit is contained in:
@@ -2,7 +2,7 @@ import { CommonModule } from '@angular/common';
|
||||
import { Component, Input } from '@angular/core';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
import { MatIconModule } from '@angular/material/icon';
|
||||
import { RouterLink } from '@angular/router';
|
||||
import { Router, RouterLink } from '@angular/router';
|
||||
import { Recipe } from '../../cookbook/type';
|
||||
import { RecipeService } from '../recipe.service';
|
||||
|
||||
@@ -20,6 +20,11 @@ export class RecipeComponent {
|
||||
this.recipe = this.recipes.get(parseInt(id))!;
|
||||
}
|
||||
|
||||
constructor(protected recipes: RecipeService) {
|
||||
constructor(protected recipes: RecipeService, private router: Router) {
|
||||
}
|
||||
|
||||
delete(): void {
|
||||
this.recipes.delete(this.recipe);
|
||||
this.router.navigateByUrl('/recipes');
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user