Generating components with the Angular CLI allows for scaffolding applications quickly. Learn what will be generated for you and how to generate quickly with shortcuts in the desired directory.
Type "ng generate component" to indicate that you want to generate a component. Then specify the name of the component. In this case I'll use "people" as the name of the component. In the code editor we see our new people folder that contains an empty style file, a simple HTML template file, the TypeScript component file, and a test file.
Also notice that there have been five file changes made -- the four new files, as well as a change to the app.module file. The people component has been imported and declared with an app.module.
As a shortcut, one generating component instead of typing out "ng generate component," there is a shorthand to type "ng," "g" for generate, "c" for component, and then the name of the component. These two statements will yield the same results.
Type "ng g c people" to indicate the people folder and "person" as the name of the new component you wish to generate. As you can see by the generated output, the person component has been created underneath the people folder.
The path you specify for generated and component is relative to the directory in which you are creating it. To create an address component underneath person, navigate it to the person directory which was just created. Once there, you can generate the address component.