|
|
|
@@ -1,8 +1,8 @@ |
|
|
|
import { Component, OnInit } from '@angular/core'; |
|
|
|
import { ActivatedRoute, Params } from '@angular/router'; |
|
|
|
import { ActivatedRoute, Params, Router } from '@angular/router'; |
|
|
|
import { FormArray, FormGroup, FormControl, Validators } from '@angular/forms'; |
|
|
|
|
|
|
|
import { RecipeService } from '../recipe.service'; |
|
|
|
import { Recipe } from '../recipe.model'; |
|
|
|
|
|
|
|
@Component({ |
|
|
|
selector: 'app-recipe-edit', |
|
|
|
@@ -15,7 +15,8 @@ export class RecipeEditComponent implements OnInit { |
|
|
|
recipeForm: FormGroup |
|
|
|
|
|
|
|
constructor(private route: ActivatedRoute, |
|
|
|
private recipeService: RecipeService) { } |
|
|
|
private recipeService: RecipeService, |
|
|
|
private router: Router) { } |
|
|
|
|
|
|
|
ngOnInit() { |
|
|
|
this.route.params.subscribe( |
|
|
|
@@ -37,6 +38,7 @@ export class RecipeEditComponent implements OnInit { |
|
|
|
} else { |
|
|
|
this.recipeService.addRecipe(this.recipeForm.value); |
|
|
|
} |
|
|
|
this.router.navigate(['../'], {relativeTo: this.route}); |
|
|
|
} |
|
|
|
|
|
|
|
onAddIngredient() { |
|
|
|
@@ -48,6 +50,10 @@ export class RecipeEditComponent implements OnInit { |
|
|
|
) |
|
|
|
} |
|
|
|
|
|
|
|
onCandel() { |
|
|
|
this.router.navigate(['../'], {relativeTo: this.route}); |
|
|
|
} |
|
|
|
|
|
|
|
private initForm() { |
|
|
|
let recipeName = ''; |
|
|
|
let recipeImagePath = ''; |
|
|
|
|