0

preDefinedSearch是对象

searchCategory是字符串,

当我更改这两个值时,在第一个事件中OnChanges包含两个值,如下所示,

Changes: Object {searchCategory: SimpleChange, preDefinedSearch: SimpleChange}

但是对于这两个属性的下一次更新没有反映,仅包含字符串值作为第一个事件后的更改值OnChnages

Changes: Object {searchCategory: SimpleChange}

下面是ngOnChanges实现:

ngOnChanges(changes: {[propertyName: string]: SimpleChange}): void {
console.log("Changes: ", changes);
if (this.searchForm) {
  for (let propName in changes) {
    if (propName === "preDefinedSearch") {
      console.log("preDefinedSearch from inside: ", changes[propName]);
    }
    if(propName === "searchCategory") {
      console.log("searchCategory from inside: ", changes[propName].currentValue);
    }
  }
}

}

4

0 回答 0