Input reaktif sudut yang diperlukan berdasarkan nilai sebelumnya
// attr declarations
fieldOne = new FormControl('',[]); // initial value and validators inside array
fieldTwo = new FormControl('', []); // initialValue and validators
// ngOnInit
fieldOne.valueChanges.
.pipe(
debounceTime(100), // dalay after every change to update your validations
distinctUntilChanged(), // only update validators when value change
tap(value => {
// depend on your options you can use switch here
if(value === 'Adhaar number'){
this.fieldTwo.setValidators([Validators.required,Validators.maxLength(12)]);
this.fieldTwo.updateValueAndValidity();
} else
if(value === 'PAN number'){
this.fieldTwo.setValidators([Validators.required,Validators.maxLength(10)]);
this.fieldTwo.updateValueAndValidity();
} else {
this.fieldTwo.setValidators([Validators.required]);
this.fieldTwo.updateValueAndValidity();
}
})
)
.subscribe()
Magnificent Macaw