我在子组件中有一个输入字段。在发生模糊事件时,此输入的值通过AppComponent传递给eventEmmiter,并为AppComponent的键属性设置一个新值。由于子组件的关键输入修饰器绑定到此属性,因此我期望在子组件中触发ngOnChanges钩子,并将前面的值和当前值设置为段落。但这不管用。
Stackblitz:https://stackblitz.com/edit/angular-klhjdf?file=app%2Fchild.component.ts
发布于 2018-01-11 19:04:16
您过早地关闭了child标记:
<child
[key]="key"> <-------------------------------- here
(triggerInputChanges)="handleKey($event)"
</child>它应该是
<child
[key]="key"
(triggerInputChanges)="handleKey($event)">
^^^^
here
</child>https://stackoverflow.com/questions/48214042
复制相似问题