summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorschencej <55326070+schencej@users.noreply.github.com>2019-12-10 17:29:31 -0500
committerGitHub <noreply@github.com>2019-12-10 17:29:31 -0500
commit8de14b3da7ec0dad8b02f5ca7a0e336c78d22522 (patch)
tree6b463557096d6c9913dfc153c27162730197abe8
parentd28256cb2efa3bd371d1e221b0411d66cf6b8345 (diff)
parente249709c792bb7e819be661a134e3a965d2a0919 (diff)
Merge pull request #18 from tuckerevans/add_page
Add page now redirects on submission
-rw-r--r--recipeBuddy/src/app/add-recipe/add-recipe.component.ts18
1 files changed, 11 insertions, 7 deletions
diff --git a/recipeBuddy/src/app/add-recipe/add-recipe.component.ts b/recipeBuddy/src/app/add-recipe/add-recipe.component.ts
index 407997c..5109c34 100644
--- a/recipeBuddy/src/app/add-recipe/add-recipe.component.ts
+++ b/recipeBuddy/src/app/add-recipe/add-recipe.component.ts
@@ -7,6 +7,8 @@ import { FormArray } from '@angular/forms';
import { Validators } from '@angular/forms';
+import { Router } from '@angular/router';
+
import { Recipe } from '../DataModels/recipe';
import { Ingredient } from '../DataModels/ingredient'
import { Step } from '../DataModels/step';
@@ -43,7 +45,8 @@ export class AddRecipeComponent {
});
constructor(private fb: FormBuilder,
- private restService: BackendService
+ private restService: BackendService,
+ private router: Router,
) { }
ngOnInit() {
@@ -99,9 +102,9 @@ export class AddRecipeComponent {
}
var steps = []
- for (i = 0; i < formData.ingredients.length; i++) {
- var tmp_timer = parseInt(formData.steps[0].timer)
- steps.push(new Step(formData.steps[0].instruct,
+ for (i = 0; i < formData.steps.length; i++) {
+ var tmp_timer = parseInt(formData.steps[i].timer)
+ steps.push(new Step(formData.steps[i].instruct,
(isNaN(tmp_timer) ? 0 : tmp_timer)
));
}
@@ -118,9 +121,10 @@ export class AddRecipeComponent {
(isNaN(cookTimeTmp) ? 0 :cookTimeTmp), //cookTime
0, //timesCooked
0, //rating
- formData.tags.split(','), //tags
- formData.photos.split(',') //photos
+ formData.tags.split(',').filter(word=> !(word==="")), //tags
+ formData.photos.split(',').filter(word=> !(word==="")) //photos
);
- this.restService.createRecipe(recipe).subscribe()
+ this.restService.createRecipe(recipe).subscribe();
+ this.router.navigate(['/']);
}
}