CLI

generate directive

Command
ng generate directive
ng generate d

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

Arguments

name

The name of the new directive.

Value Typestring

Options

export

The declaring NgModule exports this directive.

Value TypebooleanDefaultfalse
flat

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

Value TypebooleanDefaulttrue
module
Aliasm

The declaring NgModule.

Value Typestring
prefix
Aliasp

A prefix to apply to generated selectors.

Value Typestring
project

The name of the project.

Value Typestring
selector

The HTML selector to use for this directive.

Value Typestring
skip-import

Do not import this directive into the owning NgModule.

Value TypebooleanDefaultfalse
skip-tests

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

Value TypebooleanDefaultfalse
standalone

Whether the generated directive is standalone.

Value TypebooleanDefaulttrue
Jump to details