2
父模板如何让孩子和父母组件之间的Angular 2沟通工作?
<problem-form *ngIf=showProblemView (addProblem)=problemAdd($event)></problem-form>
辅元件
import { Component, Output, EventEmitter } from '@angular/core';
@Output() addproblem = new EventEmitter<string>();
onClick() {
this.addproblem.emit('something')
console.log('onSubmit')
this.active = false;
}
父事件处理
problemAdd($event) {
debugger;
console.log('eventString ')
}
我知道孩子事件从以下调试器发射。我的理解是,父母没有捕获发射的儿童事件。有任何想法吗?谢谢!
Thanks @acdcjunior我必须将我的VSCode查找设置更改为区分大小写。 StackOverflow希望我等待7分钟来接受答案。谢谢! –
感谢@tibbus昨天的回复。我解决了这个问题,因为我手动输入了我的代码到stackoverflow。在这里我做了复制/粘贴。但在这两种情况下,错误都是由于错误的变量造成的。 –