angular: Lazy loading components does not load FormModule/ngModel unable to bind
🐞 bug report
Affected Package
IVY/9/RC0
Is this a regression?
no
Description
I have set up a lazy load for a component as follows in V9 RC0
constructor(private cfr: ComponentFactoryResolver) {}
...
@ViewChild('viewContainer', {read: ViewContainerRef}) viewContainer: ViewContainerRef;
...
const {DemoComponent} = await import('../demo/demo.component');
const componentRef = this.viewContainer.createComponent(this.cfr.resolveComponentFactory(DemoComponent));
Which works and gets into the child view
<ng-container #viewContainer></ng-container>
But if i try and use any [(ngModel)]
in the lazy loaded component, i get the following issue
Can't bind to 'ngModel' since it isn't a known property of 'select'
If i import the component in the app module it works as expected, but then its already pre loaded and does not lazy load
🔥 Exception or Error
ERROR in src/app/modules/contact-manager/contact-manager.component.html(12,9): error TS8002: Can't bind to 'ngModel' since it isn't a known property of 'select'.
🌍 Your Environment
Angular Version:
Angular CLI: 9.0.0-rc.0
Node: 12.2.0
OS: darwin x64
Angular: 9.0.0-rc.0
... animations, cli, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router
Package Version
-----------------------------------------------------------
@angular-devkit/architect 0.900.0-rc.0
@angular-devkit/build-angular 0.900.0-rc.0
@angular-devkit/build-optimizer 0.900.0-rc.0
@angular-devkit/build-webpack 0.900.0-rc.0
@angular-devkit/core 9.0.0-rc.0
@angular-devkit/schematics 9.0.0-rc.0
@angular/cdk 8.2.3
@ngtools/webpack 9.0.0-rc.0
@schematics/angular 9.0.0-rc.0
@schematics/update 0.900.0-rc.0
rxjs 6.5.3
typescript 3.6.4
webpack 4.41.2
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 2
- Comments: 30 (4 by maintainers)
would be really nice if this worked