-
Notifications
You must be signed in to change notification settings - Fork 518
FormsModule should be imported in app.module.shared #986
Comments
I also found the same thing. I ended up putting it into app.module.server because I was getting errors on my initial page load saying that it didn't know what ngModel was. I haven't moved it shared yet, but will likely do that after working through some other issues. This seems like it should be part of the template. |
Spot on, I missed that too actually! Yes most everything will always go into a Shared module, only edge case scenarios where you need to dependency inject different modules into each platform will you need to use th be individual client & server modules. |
Thanks for letting us know! Would you be willing to submit a pull request that makes this change? |
@MarkPieszak - I have found that Angular services (classes decorated with @Injectable()) now need to be registered in the app.module.client.ts file. Am I missing something? |
@SteveSandersonMS Pull request #1012 has been submitted. |
You'll have to register them in both app.module.client & app.module.server.
|
Thanks I updated my article with your additional instructions. |
I was pulling my hair out yesterday on this issue. I tested imports on shared, client, and server, none of which worked. I ended up having to import the forms and reactiveforms module into the component itself. But the other thing was that I had to change [formgroup] to (formgroup). Can anyone else confirm that [formgroup] must be changed to (formgroup)? |
@Phillippe43 I've been using [formGroup]. Parenthesis are supposed to be for event binding. Based on your comment, do you have the proper casing (capital G) in [formGroup]? |
Ok, just tested on a clean project install. And everything worked as expected when imported into both app.module.client and app.module.server, as was mentioned above. |
Thanks for the info. This is now implemented. |
I was having trouble understanding why, after passing my solution to Angular 4 (I re-run yeoman from the root of my solution and fixed all the issues), I was getting an error that said:
I was very confused because this error comes when
FormsModule
isn't correctly imported, but it is imported in app.module.client. After a bit of testing, I figured out that the server-side (probably because of the pre-rendering) actually needed it as an import. I've passed the import to the app.module.shared and it fixed the issue.Is there any reason for not importing
FormsModule
from the app.module.shared? Is there something that I should do differently to not have that issue?The text was updated successfully, but these errors were encountered: