|
|
|
@@ -1,4 +1,5 @@ |
|
|
|
import { Component, OnInit } from '@angular/core'; |
|
|
|
import { Component, OnInit, ViewChild, ElementRef, EventEmitter, Output } from '@angular/core'; |
|
|
|
import { Ingredient } from '../../shared/ingredient.model'; |
|
|
|
|
|
|
|
@Component({ |
|
|
|
selector: 'app-shopping-edit', |
|
|
|
@@ -6,10 +7,18 @@ import { Component, OnInit } from '@angular/core'; |
|
|
|
styleUrls: ['./shopping-edit.component.css'] |
|
|
|
}) |
|
|
|
export class ShoppingEditComponent implements OnInit { |
|
|
|
@ViewChild('nameInput') nameInputRef: ElementRef; |
|
|
|
@ViewChild('amountInput') amountInputRef: ElementRef; |
|
|
|
@Output() ingredientAdded = new EventEmitter<Ingredient>(); |
|
|
|
|
|
|
|
constructor() { } |
|
|
|
|
|
|
|
ngOnInit() { |
|
|
|
} |
|
|
|
|
|
|
|
onAddItem() { |
|
|
|
const newIngredient = new Ingredient(this.nameInputRef.nativeElement.value, |
|
|
|
this.amountInputRef.nativeElement.value); |
|
|
|
this.ingredientAdded.emit(newIngredient); |
|
|
|
} |
|
|
|
} |