Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom-Controls not usable in different ngModules #19451

Open
lerchenreich opened this issue May 3, 2020 · 0 comments
Open

Custom-Controls not usable in different ngModules #19451

lerchenreich opened this issue May 3, 2020 · 0 comments
Labels
area: material/form-field P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent

Comments

@lerchenreich
Copy link

馃悶 bug report

Affected Package

The issue is caused by package @angular/material/form-field

Is this a regression?

No, tested only material-versions 9.1.3 and 9.2.2

Description

A Custom control does not work in different ngModules. For example, a custom-control declared in AppModule only works in components that are also declared in AppModule, but not in a lazy loaded component of another ngControl --> see errormessage. I think the purpose of a custom control is to use it in multiple components. Since lazy loading is preferred for larger projects, custom controls should also work. A bug or a missing feature?

馃敩 Minimal Reproduction

https://github.com/lerchenreich/angular-custom-control-test
  1. Serve the project (VS-Code F5)
  2. Press Button "Both declared in App-Module" --> hurra it works: the control shows "IN APP.MODULE IT WORKS"
    (The control and the component are declared in AppModule)
  3. Press Button "In different Modules declared" --> ERROR: debug-console shows the error below
    (the control is declared in AppModule, the component in lazy loaded Module1)
  4. Press Button "Both declared in Module 2! --> ERROR: debug-console shows the error below
    (the control and the component are declared in lazy loaded Module2)
    The Attribute "ngDefaultControl" heals the error "No value accessor for form control with unspecified name attribute"

An attribute like "matInput" which ist already defined in the control doesn't help

馃敟 Exception or Error




Error: mat-form-field must contain a MatFormFieldControl.
core.js:6237
message:"mat-form-field must contain a MatFormFieldControl."
stack:"Error: mat-form-field must contain a MatFormFieldControl.
    at getMatFormFieldMissingControlError (http://localhost:3041/vendor.js:100586:12)
    at MatFormField._validateControlChild (http://localhost:3041/vendor.js:101224:19)
    at MatFormField.ngAfterContentChecked (http://localhost:3041/vendor.js:101020:14)
    at callHook (http://localhost:3041/vendor.js:40203:14)
    at callHooks (http://localhost:3041/vendor.js:40163:17)
    at executeInitAndCheckHooks (http://localhost:3041/vendor.js:40103:9)
    at refreshView (http://localhost:3041/vendor.js:46591:21)
    at refreshComponent (http://localhost:3041/vendor.js:48014:9)
    at refreshChildComponents (http://localhost:3041/vendor.js:46270:9)
    at refreshView (http://localhost:3041/vendor.js:46601:13)"

馃實 Your Environment

Angular Version:




Angular CLI: 9.1.4
Node: 12.16.1
OS: win32 x64

Angular: 9.1.4
... animations, cli, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router
Ivy Workspace: Yes

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.901.4
@angular-devkit/build-angular     0.901.4
@angular-devkit/build-optimizer   0.901.4
@angular-devkit/build-webpack     0.901.4
@angular-devkit/core              9.1.4
@angular-devkit/schematics        9.1.4
@angular/cdk                      9.2.2
@angular/flex-layout              9.0.0-beta.29
@angular/localize                 9.0.0
@angular/material                 9.2.2
@ngtools/webpack                  9.1.4
@schematics/angular               9.1.4
@schematics/update                0.901.4
rxjs                              6.5.5
typescript                        3.8.3
webpack                           4.42.0

Anything else relevant?

@mmalerba mmalerba transferred this issue from angular/angular May 26, 2020
@mmalerba mmalerba added P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent area: material/form-field labels May 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: material/form-field P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent
Projects
None yet
Development

No branches or pull requests

2 participants