Skip to content

Commit 3a3bd36

Browse files
AlexanderMeldeAndrewKushnir
authored andcommitted
docs: update to new standalone default behavior (#63329)
When declaring directives, the standalone flag is set to true by default in current Angular versions. The docs for the directive decorator should correctly explain the default behavior, while still mentioning when to set it to false. PR Close #63329
1 parent 6489af7 commit 3a3bd36

File tree

1 file changed

+7
-16
lines changed

1 file changed

+7
-16
lines changed

packages/core/src/metadata/directives.ts

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -49,34 +49,25 @@ export interface DirectiveDecorator {
4949
*
5050
* ### Declaring directives
5151
*
52-
* In order to make a directive available to other components in your application, you should do
53-
* one of the following:
54-
* - either mark the directive as [standalone](guide/components/importing),
55-
* - or declare it in an NgModule by adding it to the `declarations` and `exports` fields.
56-
*
57-
* ** Marking a directive as standalone **
58-
*
59-
* You can add the `standalone: true` flag to the Directive decorator metadata to declare it as
60-
* [standalone](guide/components/importing):
52+
* By default, directives are marked as [standalone](guide/components/importing), which makes
53+
* them available to other components in your application.
6154
*
6255
* ```ts
6356
* @Directive({
64-
* standalone: true,
6557
* selector: 'my-directive',
6658
* })
67-
* class MyDirective {}
6859
* ```
6960
*
70-
* When marking a directive as standalone, please make sure that the directive is not already
71-
* declared in an NgModule.
72-
*
61+
* Please make sure that directives marked as standalone are not already declared in an NgModule.
7362
*
7463
* ** Declaring a directive in an NgModule **
75-
*
76-
* Another approach is to declare a directive in an NgModule:
64+
* If you want to declare a directive in an ngModule, add the `standalone: false` flag to the
65+
* Directive decorator metadata and add the directive to the `declarations` and `exports`
66+
* fields of your ngModule.
7767
*
7868
* ```ts
7969
* @Directive({
70+
* standalone: false,
8071
* selector: 'my-directive',
8172
* })
8273
* class MyDirective {}

0 commit comments

Comments
 (0)