Angular & Signals (283 Qs)•Part 2: HttpClient, RxJS Observables & Angular Elements (36 - 62)
How do you create directives using CLI?
You can use CLI command ng generate directive to create the directive class file. It creates the source file(src/app/components/directivename.directive.ts), the respective test file .spec.ts and declare the directive class file in root module.
Practical Code Example
bash
# Creating a directive using Angular CLI:
ng generate directive directives/auto-focus
# Generates auto-focus.directive.ts and auto-focus.directive.spec.ts