ngOnChanges(changes: SimpleChanges) {
setTimeout(() => {
console.log(changes.output,'adjaslćjkdajklsdajslk');
}, 1000)
this.confing = changes.output.currentValue;
console.log(changes.output.currentValue,'aaaaaaaaaa');
// You can also use categoryId.previousValue and
// categoryId.firstChange for comparing old and new values
if(this.output['user-activities']){
this.confing = this.output['user-activities'];
}
}
我更改了值,它位于changes.output.currentValue中,但它没有触发它。有什么建议吗?
编辑:
在ordervriewcomponent中我有这个:
getFlowTab(ordNum?: any, processCode?: any) {
let path: string = '/uomback/workflowexecutionplan/user-activities';
this.restService.get(path, { ordnum: ordNum, processCode: processCode }).subscribe(response => {
this.output['user-activities'] = response['payload'];
console.log(this.output,'u order overview');
})
}
和OnChanges我在flowtab组件中调用。当我第一次执行console.log(更改)时,除了当我填充输出并继续该对象时,我发现currentValue已更改但未被触发
答案 0 :(得分:2)
ngOnChanges
仅在@Input
值更改时触发。
如果您的currentValue
是输入元素,请转到ReactiveFormModule
并创建表单,然后订阅
this.currentValue.valueChanges.subscribe(() => {
// get notified when the value changes
});
答案 1 :(得分:0)
ngOnChanges 由角度触发。
如果您更改了同一组件中的输入变量,则不会触发它。