10
角@ViewChild()错误:预期有2个参数,但得到1个
尝试使用ViewChild时出现错误。错误是“未提供'opts'参数。” 两个@ViewChild都给出错误。 import { Component, OnInit, ElementRef, ViewChild, Output, EventEmitter } from '@angular/core'; import { Ingredient } from 'src/app/shared/ingredient.model'; @Component({ selector: 'app-shopping-edit', templateUrl: './shopping-edit.component.html', 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() …
248
angular
typescript