0

I want to validate a form using reactive form group for non form controls. I was using some custom components as part of my form. Please see the example

<form [formGroup]='formGroupName' >
  <input type='text' formControlName='control1'/>
  <!--The below component is part of some node module I cant do any changes in the below component -->
  <some-component [(value)]='model'></some-component>
</form>

 TypeScript
 this._fb.group({
   control1: ['', [Validators.required]],
   control2: ['', [Validators.required]]
 });

In the above code I want to bind control2 to some component model

1 Answer 1

1

I think that you can use

<some-component [value]="formGroupName.get('control2').value"
                (valueChange)="formGroupName.get('control2').setValue($event)"
></some-component>
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.