0

I have a recursion

app-root.component.html

<div [formGroup]="form">
some content
<app-root></app-root>
</div>

How can I use same form group and form controls in my recursion? Something like :

<div [formGroup]="form">
some content
<app-root
[formGroup]="form"
></app-root>
</div>
2
  • Not sure if it is allowed to have form groups with same name. By the way, what do you want to achieve by this? Commented May 23, 2020 at 6:30
  • I don't need the same name:) I think we can do it with Input may be. I want to bind parent form control's to recursion. I have required fields, And I have a save button, when required input field is empty in parent component, button is disabled, I want the same for my recursion. When my recursion's required field is empty, I need that save button become disabled in parent component Commented May 23, 2020 at 6:34

1 Answer 1

1

Implement ControlValueAccessor interface in app.component.ts and add NG_VALIDATORS as well.

Sign up to request clarification or add additional context in comments.

3 Comments

can I get more details from U plz?
this method works in custom form controls. here you are using app component as a form control when used recursively. so you need to implement custom validator for your whole app component so that it can be used by root app component to validate child app components.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.