Angular CurrentValue已更改,但ngOnChanges未触发?
我改变了值,它在changes.output.currentValue中,但它没有触发它。有什么建议吗 编辑: 在ordervriewcomponent中,我有以下内容:Angular CurrentValue已更改,但ngOnChanges未触发?,angular,Angular,我改变了值,它在changes.output.currentValue中,但它没有触发它。有什么建议吗 编辑: 在ordervriewcomponent中,我有以下内容: ngOnChanges(changes: SimpleChanges) { setTimeout(() => { console.log(changes.output,'adjaslćjkdajklsdajslk'); }, 1000) this.confing = c
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'];
}
}
和OnChanges,我调用flowtab组件。当我第一次执行console.log(changes)时,除了填充输出并继续该对象外,我发现currentValue已更改,但未触发它当@Input变量仅从父组件更改时,角度会触发更改。
如果更改了同一组件的输入变量,则不会触发
ngOnChanges
仅在@Input
值更改时触发
如果您的currentValue
是一个输入元素,则使用ReactiveFormModule
创建一个表单,然后订阅
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');
})
}
我不是从同一个组件触发的。你能提供更改值和位置的代码吗?如果这是有帮助的,不要忘记接受答案。你能帮我解决这个问题吗
this.currentValue.valueChanges.subscribe(() => {
// get notified when the value changes
});