Forrest logo
back to the ng tool

ng:tldr:613dd

ng: Add a new component to one's application.
$ ng generate component ${component_name}
try on your machine

This is a command for generating a new component in an Angular application using Angular CLI (Command Line Interface).

Here's a breakdown of the command:

  • ng: It is the keyword to execute the Angular CLI commands.
  • generate: It is a sub-command used to generate different code artifacts like components, services, modules, etc.
  • component: This is the specific generator that creates a new component. The component keyword is followed by the name of the component to be generated.
  • ${component_name}: This is a placeholder for the actual name of the component you want to generate. You need to replace ${component_name} with the desired name of your component, in camelCase format.

For example, if you want to generate a component named "exampleComponent", you would execute the command: ng generate component exampleComponent.

Executing this command will generate all the necessary files and folders required for the component, such as the TypeScript file (.ts), HTML template (.html), CSS/SCSS style file (.css/.scss), and a test file if configured.

This explanation was created by an AI. In most cases those are correct. But please always be careful and never run a command you are not sure if it is safe.
back to the ng tool