Angular 8 - SimpleChange 类中的firstChange 与 isFirstChange()

K.D*_*ien 8 angular

如主题中所示,prop firstChange 和方法 isFirstChange 之间的区别在哪里?使用 prop 相对于 method (或者 method 相对于 prop)有什么优势吗?两者似乎都返回相同的东西。

Mic*_*l D 4

没有区别。该isFirstChange()函数在语义上是访问成员属性的正确方法firstChange

源头来看:

export class SimpleChange {
  constructor(public previousValue: any, public currentValue: any, public firstChange: boolean) {}

  isFirstChange(): boolean {
    return this.firstChange;
  }
}
Run Code Online (Sandbox Code Playgroud)