I have a fairly complicated form with a plenty of controls in it, and i want to get value one of those inside formGroup.valueChanges subscription callback. (sample code below)
So i do a simple console.log(this.control) and it returns control which always definitely contains a "value" key with value in it, let's say "26".
However, when i try to get this value with console.log(this.control.value) in some occasions it returns null.
I tried to use setTimeOut and it works well, but it doesn't seem to me as a right way to fix the problem.
What's the secret of such behaviour?
this.someFormGroup.valueChanges
.pipe(first())
.subscribe(() => {
console.log(this.control)
// form control with value:'26' in it.
console.log(this.control.value); // null
setTimeout(() => { // works well
console.log(this.control)
// form control with value:'26' in it.
console.log(this.control.value)
// '26;
});
})