0
0
Angularframework~5 mins

Creating components with CLI in Angular - Quick Revision & Summary

Choose your learning style9 modes available
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'?
Ang generate component header
Bng create component header
Cng new component header
Dng add component header
What file is NOT created by default when generating a component?
Acomponent.json
Bcomponent.html
Ccomponent.ts
Dcomponent.spec.ts
How do you prevent the CLI from creating a test file?
A--no-test
B--skip-test-file
C--skip-tests
D--no-spec
Where does the CLI add the new component automatically?
AIn the <code>imports</code> array
BNowhere (standalone by default)
CIn the <code>providers</code> array
DIn the <code>declarations</code> array
What does the --inline-template flag do?
ASkips creating a template
BCreates a separate HTML file
CCreates a CSS file inline
DCreates the 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.