Forms Module not found in Child module

I am trying to use ReactiveFormsModule. I imported it in app.module. My component is in child module, but child module not able to get that.

Should I want to import this module in each child modules? Or is there any way to keep it in appmodule and make it work in all child modules?

Upvotes: 2

Views: 1047

Answers (1)

Ling Vu
Ling Vu

Reputation: 5181

That's the way how encapsulation in Angular works.

It prevents from invisible dependencies and makes it very clear what the module needs. How you could approach it, is by creating a SharedModule, which contains all necessary modules to import it into the respective module.

This is a very common behavior. For an example you can have a look here: how to use parent module component in child module component in angular2

Upvotes: 1

Related Questions