【发布时间】:2022-01-18 00:05:15
【问题描述】:
我正在使用 ngOnChanges,并且我已将 SimpleChange 参数设置如下。为什么我可以使用 changes.currentValue 直接访问我的输入属性,而不必使用索引获取属性?两者都有效,我很困惑为什么?
ngOnChanges(changes: SimpleChange) {
console.log('ngOnChanges called with changes value: ', changes.currentValue) // why does this work? is it because by convention it works if I have just one input property??
for (const propName in changes) {
console.log('ngOnChanges called with propName value: ', changes[propName].currentValue)
}
}
【问题讨论】:
标签: angular ngonchanges