diff --git a/src/app/shopping-list/shopping-edit/shopping-edit.component.html b/src/app/shopping-list/shopping-edit/shopping-edit.component.html
index 6326370..ff9c298 100644
--- a/src/app/shopping-list/shopping-edit/shopping-edit.component.html
+++ b/src/app/shopping-list/shopping-edit/shopping-edit.component.html
@@ -4,16 +4,24 @@
-
+
diff --git a/src/app/shopping-list/shopping-edit/shopping-edit.component.ts b/src/app/shopping-list/shopping-edit/shopping-edit.component.ts
index 19edfff..de8994b 100644
--- a/src/app/shopping-list/shopping-edit/shopping-edit.component.ts
+++ b/src/app/shopping-list/shopping-edit/shopping-edit.component.ts
@@ -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
();
constructor() { }
ngOnInit() {
}
+ onAddItem() {
+ const newIngredient = new Ingredient(this.nameInputRef.nativeElement.value,
+ this.amountInputRef.nativeElement.value);
+ this.ingredientAdded.emit(newIngredient);
+ }
}
diff --git a/src/app/shopping-list/shopping-list.component.html b/src/app/shopping-list/shopping-list.component.html
index 78ab2f9..c2cc788 100644
--- a/src/app/shopping-list/shopping-list.component.html
+++ b/src/app/shopping-list/shopping-list.component.html
@@ -1,6 +1,7 @@