components icon indicating copy to clipboard operation
components copied to clipboard

bug(dialog): custom reactive form control in a dialog created with ng-template throw error

Open nzbin opened this issue 3 years ago • 1 comments
trafficstars

Is this a regression?

  • [x] Yes, this behavior used to work in the previous version

The previous version in which this bug was not present was

v13

Description

The custom reactive form control in a dialog created with ng-template will throw the following error:

Error: NG01350: ngModel cannot be used to register form controls with a parent formGroup directive. Try using
formGroup's partner directive "formControlName" instead

Reproduction in StackBlitz

It has no problems in v12 and v13.

Reproduction

Steps to reproduce:

  1. create a custom form control using ngModel
  2. create a dialog with ng-template and a reactive form
  3. open the dialog

Expected Behavior

Don't throw errors.

Actual Behavior

Throw the error NG01350.

Environment

  • Angular: 14.1.3
  • CDK/Material: 14.1.3
  • Browser(s): Chrome latest
  • Operating System (e.g. Windows, macOS, Ubuntu):

nzbin avatar Aug 23 '22 08:08 nzbin

I'll try to solve this issue

maykonpacheco avatar Sep 12 '22 20:09 maykonpacheco

I'll try to solve this issue

Any news?

andrybany avatar Oct 18 '22 07:10 andrybany

I have the same issue, but in my case, I used cdk/dialog

mishahrokhola avatar Dec 05 '22 18:12 mishahrokhola

Same issue here. This is a real problem because I'm using a vendor component I try to inject in a MatDialog. I can't really change that behavior.

Lerado avatar Jan 11 '23 09:01 Lerado

This is so annoying. I strongly think the most reusable way of embedding pure components in dialogs is using ng-templates.

Please let us know if there is anything we can do to provide some support on this issue. @maykonpacheco

Lerado avatar Jan 16 '23 16:01 Lerado

It seems like the problem has been fixed in angular 16 with this PR

mishahrokhola avatar Jun 09 '23 08:06 mishahrokhola

It seems like the problem has been fixed in angular 16 with this PR

I think that is possible. Especially with the new reactivity model.

Lerado avatar Jun 09 '23 08:06 Lerado