Sridhar Natuva
Sridhar Natuva

Reputation: 211

Can i rename the root path when creating module or component from angular cli?

I tried to rename the app to custom name and app module to custom module. and it worked well, But when i create any component or sub module with ng g m sub-module It takes the path as app/moduleName/componentName. how can i make custom-name/moduleName/componentName when creating a module from cli command.

Where do i customize this setting?

Upvotes: 0

Views: 462

Answers (1)

Anarno
Anarno

Reputation: 1640

Simply write the full path what you want, and the last segment will be the name of the module ex: ng g m users/UserDetails <--- will generates a UserDetailsModule in the users folder. You can do this with the component generate command, like this: ng g c users/UserDetails --m users/UserDetails.module <--- this will generates a component and will declares in the UserDetailsModule. See more options here.

Update 1

I found a solution: use ../ in the path, like this: ng g c ../user but when you use this, the CLI doesn't finds any module and will cries, soo you need add an extra option and the final command will be: ng g c ../user --skipImport.

Updadte 2

If you specifies the declaration modul, you can skip the --skipImport flag, like this: ng g c ../dashboard --module app/app.module

Upvotes: 1

Related Questions