Guest User

Untitled

a guest
Jul 19th, 2018
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.33 KB | None | 0 0
  1. import { Component, OnInit, ViewChild, ElementRef, EventEmitter, Output } from '@angular/core';
  2. import { Ingredient } from '../../shared/Ingredient.model';
  3. @Component({
  4. selector: 'app-shopping-list-edit',
  5. templateUrl: './shopping-list-edit.component.html',
  6. styleUrls: ['./shopping-list-edit.component.css']
  7. })
  8. export class ShoppingListEditComponent implements OnInit {
  9. @ViewChild('name') ingredientName:ElementRef;
  10. @ViewChild('amount') ingredientAmount:ElementRef;
  11. @Output() inputValue = new EventEmitter<Ingredient>();
  12.  
  13.  
  14. constructor() { }
  15.  
  16. ngOnInit() {
  17. }
  18. onSubmit(){
  19. const iname = this.ingredientName.nativeElement.value;
  20. const iamount = this.ingredientAmount.nativeElement.value;
  21. loadedIngredient:Ingredient = new Ingredient(iname,iamount);
  22. this.inputValue.emit(loadedIngredient);
  23. }
  24.  
  25. }
  26.  
  27. ERROR in src/app/shopping-list/shopping-list-edit/shopping-list-edit.component.t s(21,4): error TS7028: Unused label. src/app/shopping-list/shopping-list-edit/shopping-list-edit.component.ts(21,21): error TS2539: Cannot assign to 'Ingredient' because it is not a variable. src/app/shopping-list/shopping-list-edit/shopping-list-edit.component.ts(22,25): error TS2304: Cannot find name 'loadedIngredient'.
  28.  
  29. import { Component, OnInit, ViewChild, ElementRef, EventEmitter, Output } from '@angular/core';
  30. import { Ingredient } from '../../shared/Ingredient.model';
  31.  
  32. @Component({
  33. selector: 'app-shopping-list-edit',
  34. templateUrl: './shopping-list-edit.component.html',
  35. styleUrls: ['./shopping-list-edit.component.css']
  36. })
  37. export class ShoppingListEditComponent implements OnInit {
  38. @ViewChild('name') ingredientName:ElementRef;
  39. @ViewChild('amount') ingredientAmount:ElementRef;
  40. @Output() inputValue = new EventEmitter<Ingredient>();
  41.  
  42. loadedIngredient: Ingredient;
  43.  
  44. constructor() { }
  45.  
  46. ngOnInit() {}
  47.  
  48. onSubmit(){
  49. const iname = this.ingredientName.nativeElement.value;
  50. const iamount = this.ingredientAmount.nativeElement.value;
  51. this.loadedIngredient: Ingredient = new Ingredient(iname, iamount);
  52. this.inputValue.emit(this.loadedIngredient);
  53. }
  54. }
  55.  
  56. onSubmit(){
  57. const iname = this.ingredientName.nativeElement.value;
  58. const iamount = this.ingredientAmount.nativeElement.value;
  59. const loadedIngredient: Ingredient = new Ingredient(iname, iamount);
  60. this.inputValue.emit(this.loadedIngredient);
  61. }
Add Comment
Please, Sign In to add comment