Create a form component
- โ๏ธGenerate a new componentGet used to the Angular CLI to create new components
- โ๏ธUnderstand the Angular CLI optionsLearn how to customize the component generation process with the Angular CLI
Component creation
๐ Instructions
-
Run the following command in your terminal:
or the shorthand version:
-
You should see a new folder called
task-form
in thesrc/app
folder.
Angular CLI options
The Angular CLI provides multiple options to customize the component generation process. You can add these options upon the previous command. For example, to avoid generating a component in a new folder, you can run the following command:
If you want some options to be the default for all components, you can add them to the angular.json
file located at the root of your project.
For the current project, you already have the following options set:
It avoids creating test files and deactivate the new Standalone feature.
These options were added to the angular.json
file when you created the project with the Angular CLI.
This course doesnโt cover testing, thatโs a topic for another course.
โ๏ธ What you learned
We used the Angular CLI to create a new component. Thatโs the second component you created in this project. Such a task is a common task in Angular development, and the Angular CLI makes it easy to create new components. If needed, you can customize the component generation process with the Angular CLI options.
๐ฆ Quiz
What is the file used to ocnfigure the Angular CLI options for component generation?
angular.json
package.json
tsconfig.json