0
0
Angularframework~20 mins

Creating components with CLI in Angular - Practice Exercises

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Angular CLI Component Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
📝 Syntax
intermediate
2:00remaining
Angular CLI command to create a standalone component
Which Angular CLI command correctly creates a new standalone component named profile?
Ang generate component profile --standalone
Bng generate component profile --module=app.module.ts
Cng generate component profile --skip-import
Dng generate component profile --inline-style
Attempts:
2 left
💡 Hint
Standalone components require the --standalone flag to be created via CLI.
component_behavior
intermediate
2:00remaining
Effect of skipping style file when creating a component
What will happen if you run ng generate component dashboard --skip-style?
AThe component is created without a CSS/SCSS style file.
BThe component will have inline styles instead of a separate file.
CThe CLI will throw an error and stop the creation.
DThe component will have an empty style file generated.
Attempts:
2 left
💡 Hint
The --skip-style flag controls whether a separate style file is created.
🔧 Debug
advanced
2:00remaining
Why does this CLI command fail?
You run ng generate component user/profile but get an error. What is the most likely cause?
AThe CLI cannot create components inside subfolders without the <code>--module</code> flag.
BThe <code>user</code> folder does not exist and CLI cannot create nested folders.
CThe CLI requires the <code>--flat</code> flag to create nested components.
DThe CLI expects folder names without slashes; use dashes instead.
Attempts:
2 left
💡 Hint
Check if the folder path exists or if CLI can create it automatically.
state_output
advanced
2:00remaining
Result of creating a component with inline template and style
What files and content will be generated by ng generate component header --inline-template --inline-style?
AOnly the TypeScript and CSS files are created; HTML is inline.
BSeparate HTML and CSS files are created, but empty because of inline flags.
CA TypeScript file with template and styles inside, no separate HTML or CSS files.
DOnly the TypeScript and HTML files are created; CSS is inline.
Attempts:
2 left
💡 Hint
Inline flags embed template and styles inside the component TS file.
🧠 Conceptual
expert
2:00remaining
Understanding Angular CLI component creation flags
Which Angular CLI flag ensures a component is created without being declared in any NgModule?
A--module=none
B--skip-import
C--flat
D--standalone
Attempts:
2 left
💡 Hint
Standalone components do not require NgModule declarations.