FormsModule not shared with Feature Modules
See original GitHub issueI’m submitting a …
[x] bug report
[ ] feature request
[ ] support request
Current behavior
Excuse my ignorance if this is expected behavior, but when I create a feature module (lazy loaded module using a route like { path: 'user', loadChildren: 'app/user/user.module#UserModule' }), I am required to import the FormsModule in the feature module even if it is already imported in the root/app module. It appears that this works for some modules (such as the BrowserModule), but not for the FormsModule. I get the error Can't bind to 'ngModel' since it isn't a known property of 'input'. when using [(ngModel)] in a form unless I actually import the FormsModule in the feature module.
Expected/desired behavior
My understanding is that if you import a module in higher-level module, that the imported module should be available to all child/feature modules. This should work for FormsModule like it does for BrowserModule.
Reproduction of the problem You can see this behavior in this Plunk: http://plnkr.co/edit/yOX8nBsJdkLEG207kEhb?p=preview
I’ve modified the Heroes Plunk from the Routing example to add a feature module. Notice that if you click on the Feature link on the page that it attempts to load the feature module but logs an error in the console because it can’t find ngModel even though FormsModule is imported in /app/app.module.ts. However, if you uncomment line #15 in /app/feature/feature.module.ts (which imports FormsModule) then it works fine. Also notice that the *ngFor which comes from the BrowserModule works fine even though that is not loaded explicitly in the feature module (only in the app module).
What is the expected behavior?
We shouldn’t have to import FormsModule in a feature module if it is already imported in higher module.
What is the motivation / use case for changing the behavior? Consistency with other imports.
Environment:
- Angular version: RC5
- Browser: Chrome 52.0.2743.116
- Language: TypeScript
Issue Analytics
- State:
- Created 7 years ago
- Comments:8 (1 by maintainers)

Top Related StackOverflow Question
@jmcooper yes, NgModule providers get put into the root injector, so they do work differently than pipes/directives.
So why does ngFor (which comes from BrowserModule) not have to be imported?
On Sep 5, 2016 10:41 PM, “Anthony” notifications@github.com wrote: