Recall & Review
beginner
What command do you use to create a new Angular component using the CLI?
Use
ng generate component component-name or the shortcut ng g c component-name to create a new component.Click to reveal answer
beginner
What files are created when you generate a new Angular component with the CLI?
The CLI creates four files:
.ts (TypeScript logic), .html (template), .css or .scss (styles), and .spec.ts (test file).Click to reveal answer
intermediate
Does the CLI update your Angular module when you generate a component?
No, since Angular 17 the CLI generates standalone components by default and does not add them to the
declarations array of any module.Click to reveal answer
intermediate
How can you create a component without generating a test file using the CLI?
Add the flag
--skip-tests to the generate command, like ng g c component-name --skip-tests.Click to reveal answer
intermediate
What does the
--inline-style flag do when creating a component with the CLI?It puts the component's CSS styles directly inside the TypeScript file instead of creating a separate CSS file.
Click to reveal answer
Which command creates a new Angular component named 'header'?
✗ Incorrect
The correct command is
ng generate component header or its shortcut ng g c header.What file is NOT created by default when generating a component?
✗ Incorrect
The CLI does not create a
.json file for components by default.How do you prevent the CLI from creating a test file?
✗ Incorrect
Use the flag
--skip-tests to skip generating test files.Where does the CLI add the new component automatically?
✗ Incorrect
Since Angular 17, new components are standalone by default and do not get added to any module array.
What does the
--inline-template flag do?✗ Incorrect
The
--inline-template flag puts the HTML template inside the TypeScript file.Explain how to create a new Angular component using the CLI and what files are generated.
Think about the command and what happens after running it.
You got /3 concepts.
Describe how to customize component creation with CLI flags like skipping tests or using inline styles.
Flags change what files or code structure the CLI generates.
You got /3 concepts.