Create Form Component
Discover avandeced options for generating a new component.
Creating Components
Section titled “Creating Components”Instructions
Section titled “Instructions”-
Run the following command in your terminal:
Terminal window ng generate component task-formor the short version
Terminal window ng g c task-form -
You should see a new folder called task-form in the
src/appdirectory.src└─ app└─ task-form└─ task-form.ts└─ task-form.html└─ task-form.css
Angular CLI Options
Section titled “Angular CLI Options”The Angular CLI provides several options to customize the component generation process. You can add these options when running the previous command. For example, to avoid generating a component in a new folder, you can run the following command:
ng generate component task-form --flator the short version:
ng g c task-form --flatIf you want certain options to be set by default for all components, you can add them to the angular.json file located at the root of your project.
For the current project, we have already defined the following option:
"@schematics/angular:component": { "skipTests": true},This avoids creating test files to reduce the complexity of the current tutorial.
The option was added to the angular.json file when we created the project with the Angular CLI.
This tutorial doesn’t cover knowledge about testing. This will be an important topic to master later.
You used the Angular CLI to create a new component. This is the second component you’ve created in this project. Such an action is common in Angular development, and the Angular CLI makes this process easier and more efficient. If needed, you can customize the component generation process with Angular CLI options.