Javascript $onChanges不';将项推送到数组时,无法调用
我使用Angular 1.5.3和typescriptJavascript $onChanges不';将项推送到数组时,无法调用,javascript,angularjs,typescript,Javascript,Angularjs,Typescript,我使用Angular 1.5.3和typescript 我有一个外部和一个内部组件,其中外部组件持有一个名为数组值的数组,我通过将其传递给内部组件,我不熟悉angular1,但如果变化检测的工作原理与Angular2相同,然后添加到数组实际上不会触发更改检测,因为数组引用不会更改。(见本问题的答案)。这可能对angular1完全无效:-)@DylanMeeus谢谢你的链接,也许是同一个问题。不知何故,我甚至没有注意到使用doCheck…我也有这个问题我不熟悉angular1,但如果更改检测的工作
我有一个
外部
和一个内部
组件,其中外部
组件持有一个名为数组值
的数组,我通过将其传递给内部
组件,我不熟悉angular1,但如果变化检测的工作原理与Angular2相同,然后添加到数组实际上不会触发更改检测,因为数组引用不会更改。(见本问题的答案)。这可能对angular1完全无效:-)@DylanMeeus谢谢你的链接,也许是同一个问题。不知何故,我甚至没有注意到使用doCheck…我也有这个问题我不熟悉angular1,但如果更改检测的工作原理与Angular2相同,那么添加到数组实际上不会触发更改检测,因为数组引用不会更改。(见本问题的答案)。这可能对angular1完全无效:-)@DylanMeeus谢谢你的链接,也许是同一个问题。不知何故,我甚至没有注意到使用多切克…我也有这个问题
class InnerComponent {
controller: Function = InnerController;
bindings: any = {
arrayValue : "<"
};
...
}
public $onChanges(changes: any){
this.onChangesCalledCounter++;
console.log(changes);
}
public switchArrayValue(): void {
if(this.arrayValue === this.fruits){
this.arrayValue = this.vegetables;
} else {
this.arrayValue = this.fruits;
}
}
public switchArrayValue(): void {
this.arrayValue.push("hello, world!");
}