summaryrefslogtreecommitdiff
path: root/recipeBuddy/src/app/recipe-card/recipe-card.component.ts
diff options
context:
space:
mode:
Diffstat (limited to 'recipeBuddy/src/app/recipe-card/recipe-card.component.ts')
-rw-r--r--recipeBuddy/src/app/recipe-card/recipe-card.component.ts60
1 files changed, 60 insertions, 0 deletions
diff --git a/recipeBuddy/src/app/recipe-card/recipe-card.component.ts b/recipeBuddy/src/app/recipe-card/recipe-card.component.ts
new file mode 100644
index 0000000..a9a4618
--- /dev/null
+++ b/recipeBuddy/src/app/recipe-card/recipe-card.component.ts
@@ -0,0 +1,60 @@
+import {Component,OnInit} from '@angular/core';
+import{BackendService} from '../REST_service/backend.service';
+import{Recipe} from '../DataModels/recipe';
+
+/**
+ * @title Card with multiple sections
+ */
+@Component({
+ selector: 'RecipeCardComponent',
+ templateUrl: 'recipe-card.component.html',
+ styleUrls: ['recipe-card.component.css']
+})
+export class RecipeCardComponent implements OnInit {
+
+ constructor(private restService: BackendService) {}
+
+
+ recipes: Recipe[] = []; //array of recipe objects
+
+ ngOnInit() {
+ this.restService.getRecipes().subscribe(
+ res => {
+ var i: number;
+ for(i = 0; i < res.length; i++) {
+ this.restService.getRecipe(res[i]).subscribe(
+ res2 => {
+ this.recipes = [...this.recipes, res2]
+ console.log(res2.photos)
+ }, err => {/*Deal with error*/}, () => {/*Code for complete observable*/}
+
+ );
+ }
+ },
+ err => {
+//Deal with error
+ },
+ () => {
+//Complete observable
+ }
+);
+ }
+
+ shoppingCart() {
+ /**Code here to open shopping cart */
+ }
+
+ cookPage(id){
+ /**Code here to go to cook page for recipe with id */
+ //this.recipes[id];
+ }
+
+ edit(id) {
+ /**Code here to edit recipe with id */
+ }
+
+ delete(id) {
+ /**Code here to delete recipe with id */
+ }
+}
+ \ No newline at end of file