-
Notifications
You must be signed in to change notification settings - Fork 0
/
recipelist.component.ts.old
64 lines (45 loc) · 1.56 KB
/
recipelist.component.ts.old
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
62
63
64
import { Component, OnInit } from '@angular/core';
import { NgbModule, NgbModal } from '@ng-bootstrap/ng-bootstrap';
import { PantryService } from '../pantry.service'
import { RecipeModalComponent } from '../recipe-modal/recipe-modal.component'
@Component({
selector: 'app-recipelist',
templateUrl: './recipelist.component.html',
styleUrls: ['./recipelist.component.css']
})
export class RecipelistComponent implements OnInit {
public recipes
recipe_full
constructor(
private pantryService: PantryService,
private modalService: NgbModal
) { }
ngOnInit(): void {
this.recipes = this.pantryService.getRecipes()
}
viewRecipeModal(recipe) {
// console.log(recipe)
var me = this
let recipeloader = function(recipe : string) : Promise<{rfull : Object}>{
return new Promise((resolve) => {
// console.log(recipe, ' <- resolved? and loaded?')
me.recipe_full = me.pantryService.loadRecipe(recipe)
setTimeout(() => {
resolve({rfull:me.recipe_full})
}, 2000);
})
}
recipeloader(recipe).then((rfull) => {
this.recipe_full = rfull
console.log(rfull)
this.openModal()
// console.log('yeah?')
// return this.openModal()
})
// this.recipe_full = this.pantryService.loadRecipe(recipe)
}
openModal(){
const modalRef = this.modalService.open(RecipeModalComponent, { centered: true, size: 'lg'})
modalRef.componentInstance.data = this.recipe_full
}
}