@nx/angular:directive

Creates a new, generic directive definition in the given project.

Usage

nx generate directive ...
nx g d ... #same

By default, Nx will search for directive in the default collection provisioned in workspace.json.

You can specify the collection explicitly as follows:

nx g @nx/angular:directive ...
Nx 15 and lower use @nrwl/ instead of @nx/

Show what will be generated without writing to disk:

nx g directive ... --dry-run

Options

name

Required
string

The name of the new directive.

project

Required
string

The name of the project.

export

boolean
Default: false

The declaring NgModule exports this directive.

flat

boolean
Default: true

When true (the default), creates the new files at the top level of the current project.

module

m
string

The filename of the declaring NgModule.

path

string
Format: path

The path at which to create the interface that defines the directive, relative to the workspace root.

prefix

p
oneOf [string, string]

A prefix to apply to generated selectors.

skipTests

boolean
Default: false

Do not create "spec.ts" test files for the new class.

skipImport

boolean
Default: false

Do not import this directive into the owning NgModule.

selector

string
Format: html-selector

The HTML selector to use for this directive.

standalone

boolean
Default: false

Whether the generated directive is standalone. Note: This is only supported in Angular versions >= 14.1.0.

skipFormat

boolean
Default: false

Skip formatting of files.