Reputation: 13875
I am attempting to use Angular CLI with the latest JavaScriptServices AspNetCore Angular Spa template.
I used to simply just copy and pase a .angular-cli.json file in the root directory of my project and change "root": to "ClientApp" and would be good to go.
However, now with this new version of the template when I run 'ng g component mycomponent' it fails because it can't find app.module.ts. The reason for this is because in this new template they split app.module.ts into 3:
app.module.client.ts, app.module.server.ts, app.module.shared.ts
Any ideas on how to still make this work?
Upvotes: 2
Views: 833
Reputation: 341
[SOLUTION]
Open app.client.module.ts: prepend the declaration with 3 dots “...” and wrap the declaration in brackets.
For example: [...sharedConfig.declarations, <MyComponent>]
Open boot-client.ts: update your import to use the new app.client.module reference.
For example: import { AppModule } from './app/app.client.module';
Now try to generate the new component: ng g component my-component
[EXPLANATION]
Angular CLI looks for a file named app.module.ts in your project, and tries to find a references for the declarations property to import the component. This should be an array (as the sharedConfig.declarations is), but the changes do not get applied
[SOURCES]
Upvotes: 2