summaryrefslogtreecommitdiff
path: root/recipeBuddy/src/app/recipe-card/recipe-card.component.ts
blob: bd44316ba3f1e960548ffa3229eed8310a19c512 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import {Component,OnInit} from '@angular/core';
import{BackendService} from '../REST_service/backend.service';

/**
 * @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 = []; //array of recipe objects
	mynumbers = [];

  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.push(res2)
				}, err => {/*Deal with error*/}, () => {/*Code for complete observable*/}
     );
    }
  },
  err => {
//Deal with error
  },
 () => {
//Complete observable
  }
);
	for(var i = 0; i <10; ++i)
	{
		mynumbers.push(i);
	}
  }
  
  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 */
  }
}