You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

25 lines
765 B

  1. import { Component, OnInit, ViewChild, ElementRef, EventEmitter, Output } from '@angular/core';
  2. import { Ingredient } from '../../shared/ingredient.model';
  3. @Component({
  4. selector: 'app-shopping-edit',
  5. templateUrl: './shopping-edit.component.html',
  6. styleUrls: ['./shopping-edit.component.css']
  7. })
  8. export class ShoppingEditComponent implements OnInit {
  9. @ViewChild('nameInput') nameInputRef: ElementRef;
  10. @ViewChild('amountInput') amountInputRef: ElementRef;
  11. @Output() ingredientAdded = new EventEmitter<Ingredient>();
  12. constructor() { }
  13. ngOnInit() {
  14. }
  15. onAddItem() {
  16. const newIngredient = new Ingredient(this.nameInputRef.nativeElement.value,
  17. this.amountInputRef.nativeElement.value);
  18. this.ingredientAdded.emit(newIngredient);
  19. }
  20. }