我最近开始在应用程序中实现延迟加载。我想知道,除了手动创建之外,是否还有其他方法可以在 angle-cli 应用程序中生成一个新模块,同时创建 outinging.module.ts?
I was searching about this a bit and found some article which has a very good explanation for different kind of commands.
The Ultimate Angular CLI Reference
So basically, there's no separate command to create routing.module file. But, that can be created while on the creation of the module:
ng generate module [module-name] --routing
or the shorthand version of the command:
ng g m [module-name] --routing
... will create the module and add the mappings/metadata linkings.
Module with Routing Create CMD :-
ng g m [ModuleName] --routing
ng generate module ModulName --flat --module=app
ng g c componanentName
ng g c sub-folder/componentName
ng g m sub-folder/moduleName --routing
Creates both module and routing simultaneously in the same folder.
ng g m sub-folder/module-name --routing
Creates the only module.
ng g m sub-folder/module-name
I am late to the party :) but here is how I generate a module, routing for the module and component all at one go and inside the same directory
module
routing
component
From the src/app/ directory type in the following command to generate a module, routing and component called 'my-page'
src/app/
ng g m my-page --routing=true && ng g c my-page --skip-tests=true -m=my-page
If you want the tests to be generated then do not use the skip-tests argument.
Late but very useful.
ng g m about --module app --route about
The above command will generate about module with about component and add lazy load route at app module for routing about route.
you can test this code
ng g m landing --route landing --module app
You can use
// module and routing -> ng g m name --routing // component with module and routing -> ng g c name && ng g m name --routing -> ng g m name --routing && ng g c name -m=name`
Simple command for Create a Module with routing..
ng g m [module_name] --routing