Angular 9 References/ CLI

Directive generator

This is the documentation for Angular 9.
You can switch to the latest version Angular 10.
ng generate directive [name] [--[argument]=[value]]
ng generate d

Create an Angular directive.



Specifies if declaring module exports the directive.
Type boolean
Default false


Flag to indicate if a dir is created.
Type boolean
Default true


Specifies whether to apply lint fixes after generating the directive.
Type boolean
Default false


Allows specification of the declaring module.
Type string
Aliases m


The prefix to apply to generated selectors.
Type string
Aliases p


The name of the project.
Type string
Default projectName


The selector to use for the directive.
Type string


Flag to skip the module import.
Type boolean
Default false


When true, does not create `spec.ts` test files for the new class.
Type boolean
Default false