0
0
Angularframework~10 mins

Creating a service with CLI in Angular - Interactive Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to generate a new Angular service using the CLI.

Angular
ng generate [1] my-service
Drag options to blanks, or click blank then click option'
Aservice
Bcomponent
Cmodule
Ddirective
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'component' instead of 'service' will create a component, not a service.
Forgetting to specify the type after 'ng generate'.
2fill in blank
medium

Complete the command to create a service with the CLI and skip the test file generation.

Angular
ng generate service my-service [1]
Drag options to blanks, or click blank then click option'
A--noTest
B--skip-tests
C--skipTest
D--no-tests
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect flag names like '--no-tests' which are not recognized.
Omitting the flag and getting test files generated.
3fill in blank
hard

Fix the error in the command to generate a service named 'data' inside a folder 'shared'.

Angular
ng generate service [1]/data
Drag options to blanks, or click blank then click option'
Ashared
Bshare
Cshared/
D/shared
Attempts:
3 left
💡 Hint
Common Mistakes
Adding a trailing slash after the folder name.
Adding a leading slash before the folder name.
4fill in blank
hard

Fill in the blanks to generate a service named 'auth' in the 'core' folder and make it provided in root.

Angular
ng generate service [1]/[2] --[3]
Drag options to blanks, or click blank then click option'
Acore
Bauth
CprovidedIn=root
DprovidedInRoot
Attempts:
3 left
💡 Hint
Common Mistakes
Using kebab-case for the flag instead of camelCase.
Swapping folder and service names.
5fill in blank
hard

Fill all three blanks to generate a service named 'logger' in the 'utils' folder, skip tests, and specify flat structure.

Angular
ng generate service [1]/[2] --[3] --skip-tests
Drag options to blanks, or click blank then click option'
Autils
Blogger
Cflat
Dflat-structure
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'flat-structure' instead of 'flat' for the flag.
Omitting the folder or service name.