Skip to content

Commit 6189457

Browse files
josmar-crwdstffngthePunderWoman
authored andcommitted
docs: improve markdown (#45590)
improve markdown for documentation. Duplicate of #45325 that targets 13.3.x. PR Close #45590
1 parent 09c5c18 commit 6189457

File tree

250 files changed

+19089
-24001
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

250 files changed

+19089
-24001
lines changed

aio/content/cli/cache.md

Lines changed: 33 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11

22
# Persistent disk cache
3+
34
Angular CLI saves a number of cachable operations on disk by default.
45

56
When you re-run the same build, the build system restores the state of the previous build and re-uses previously performed operations, which decreases the time taken to build and test your applications and libraries.
67

78
To amend the default cache settings, add the `cli.cache` object to your [Workspace Configuration](guide/workspace-config).
89
The object goes under `cli.cache` at the top level of the file, outside the `projects` sections.
910

10-
```json
11+
<code-example format="json" language="json">
12+
1113
{
12-
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
14+
"$schema": "./node_modules/&commat;angular/cli/lib/config/schema.json",
1315
"version": 1,
1416
"cli": {
1517
"cache": {
@@ -18,27 +20,35 @@ The object goes under `cli.cache` at the top level of the file, outside the `pro
1820
},
1921
"projects": {}
2022
}
21-
```
23+
24+
</code-example>
2225

2326
For more information, see [cache options](guide/workspace-config#cache-options).
2427

2528
### Enabling and disabling the cache
26-
Caching is enabled by default. To disable caching run the following command:
2729

28-
```bash
30+
Caching is enabled by default.
31+
To disable caching run the following command:
32+
33+
<code-example format="shell" language="shell">
34+
2935
ng config cli.cache.enabled false
30-
```
36+
37+
</code-example>
3138

3239
To re-enable caching, set `cli.cache.enabled` to `true`.
3340

3441
### Cache environments
42+
3543
By default, disk cache is only enabled for local environments.
3644

3745
To enable caching for all environments, run the following command:
3846

39-
```bash
47+
<code-example format="shell" language="shell">
48+
4049
ng config cli.cache.environment all
41-
```
50+
51+
</code-example>
4252

4353
For more information, see `environment` in [cache options](guide/workspace-config#cache-options).
4454

@@ -50,26 +60,33 @@ The Angular CLI checks for the presence and value of the `CI` environment variab
5060

5161
### Cache path
5262

53-
By default, `.angular/cache` is used as a base directory to store cache results. To change this path, run the following command:
63+
By default, `.angular/cache` is used as a base directory to store cache results.
64+
To change this path, run the following command:
65+
66+
<code-example format="shell" language="shell">
5467

55-
```bash
5668
ng config cli.cache.path ".cache/ng"
57-
```
69+
70+
</code-example>
5871

5972
### Clearing the cache
6073

6174
To clear the cache, run one of the following commands.
6275

6376
To clear the cache on Unix-based operating systems:
6477

65-
```bash
78+
<code-example format="shell" language="shell">
79+
6680
rm -rf .angular/cache
67-
```
81+
82+
</code-example>
6883

6984
To clear the cache on Windows:
7085

71-
```bash
86+
<code-example format="shell" language="shell">
87+
7288
rmdir /s /q .angular\cache
73-
```
7489

75-
For more information, see [rm command](https://man7.org/linux/man-pages/man1/rm.1.html) and [rmdir command](https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/rmdir).
90+
</code-example>
91+
92+
For more information, see [rm command](https://man7.org/linux/man-pages/man1/rm.1.html) and [rmdir command](https://docs.microsoft.com/windows-server/administration/windows-commands/rmdir).

aio/content/cli/index.md

Lines changed: 46 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -7,40 +7,47 @@ The Angular CLI is a command-line interface tool that you use to initialize, dev
77
Major versions of Angular CLI follow the supported major version of Angular, but minor versions can be released separately.
88

99
Install the CLI using the `npm` package manager:
10-
<code-example language="bash">
11-
npm install -g @angular/cli
10+
11+
<code-example format="shell" language="shell">
12+
13+
npm install -g &commat;angular/cli
14+
1215
</code-example>
1316

14-
For details about changes between versions, and information about updating from previous releases,
15-
see the Releases tab on GitHub: https://github.com/angular/angular-cli/releases
17+
For details about changes between versions, and information about updating from previous releases, see the Releases tab on GitHub: https://github.com/angular/angular-cli/releases
1618

1719
## Basic workflow
1820

1921
Invoke the tool on the command line through the `ng` executable.
2022
Online help is available on the command line.
21-
Enter the following to list commands or options for a given command (such as [generate](cli/generate)) with a short description.
23+
Enter the following to list commands or options for a given command \(such as [generate](cli/generate)\) with a short description.
24+
25+
<code-example format="shell" language="shell">
2226

23-
<code-example language="bash">
2427
ng help
2528
ng generate --help
29+
2630
</code-example>
2731

2832
To create, build, and serve a new, basic Angular project on a development server, go to the parent directory of your new workspace use the following commands:
2933

30-
<code-example language="bash">
34+
<code-example format="shell" language="shell">
35+
3136
ng new my-first-project
3237
cd my-first-project
3338
ng serve
39+
3440
</code-example>
3541

3642
In your browser, open http://localhost:4200/ to see the new application run.
3743
When you use the [ng serve](cli/serve) command to build an application and serve it locally, the server automatically rebuilds the application and reloads the page when you change any of the source files.
3844

3945
<div class="alert is-helpful">
4046

41-
When you run `ng new my-first-project` a new folder, named `my-first-project`, will be created in the current working directory. Since you want to be able to create files inside that folder, make sure you have sufficient rights in the current working directory before running the command.
47+
When you run `ng new my-first-project` a new folder, named `my-first-project`, will be created in the current working directory.
48+
Since you want to be able to create files inside that folder, make sure you have sufficient rights in the current working directory before running the command.
4249

43-
If the current working directory is not the right place for your project, you can change to a more appropriate directory by running `cd <path-to-other-directory>` first.
50+
If the current working directory is not the right place for your project, you can change to a more appropriate directory by running `cd <path-to-other-directory>`.
4451

4552
</div>
4653

@@ -58,52 +65,68 @@ You can edit the generated files directly, or add to and modify them using CLI c
5865
Use the [ng generate](cli/generate) command to add new files for additional components and services, and code for new pipes, directives, and so on.
5966
Commands such as [add](cli/add) and [generate](cli/generate), which create or operate on applications and libraries, must be executed from within a workspace or project folder.
6067

61-
* See more about the [Workspace file structure](guide/file-structure).
68+
* See more about the [Workspace file structure](guide/file-structure).
6269

6370
### Workspace and project configuration
6471

6572
A single workspace configuration file, `angular.json`, is created at the top level of the workspace.
6673
This is where you can set per-project defaults for CLI command options, and specify configurations to use when the CLI builds a project for different targets.
6774

6875
The [ng config](cli/config) command lets you set and retrieve configuration values from the command line, or you can edit the `angular.json` file directly.
69-
Note that option names in the configuration file must use [camelCase](guide/glossary#case-types), while option names supplied to commands must be dash-case.
7076

71-
* See more about [Workspace Configuration](guide/workspace-config).
77+
<div class="alert is-helpful">
78+
79+
**NOTE**: <br />
80+
Option names in the configuration file must use [camelCase](guide/glossary#case-types), while option names supplied to commands must be dash-case.
81+
82+
</div>
83+
84+
* See more about [Workspace Configuration](guide/workspace-config).
7285

7386
## CLI command-language syntax
7487

7588
Command syntax is shown as follows:
7689

7790
`ng` *commandNameOrAlias* *requiredArg* [*optionalArg*] `[options]`
7891

79-
* Most commands, and some options, have aliases. Aliases are shown in the syntax statement for each command.
92+
* Most commands, and some options, have aliases.
93+
Aliases are shown in the syntax statement for each command.
8094

81-
* Option names are prefixed with a double dash (--).
82-
Option aliases are prefixed with a single dash (-).
95+
* Option names are prefixed with a double dash \(`--`\) characters.
96+
Option aliases are prefixed with a single dash \(`-`\) character.
8397
Arguments are not prefixed.
8498
For example:
85-
<code-example language="bash">
86-
ng build my-app -c production
99+
100+
<code-example format="shell" language="shell">
101+
102+
ng build my-app -c production
103+
87104
</code-example>
88105

89-
* Typically, the name of a generated artifact can be given as an argument to the command or specified with the --name option.
106+
* Typically, the name of a generated artifact can be given as an argument to the command or specified with the `--name` option.
90107

91-
* Argument and option names can be given in either
92-
[camelCase or dash-case](guide/glossary#case-types).
93-
`--myOptionName` is equivalent to `--my-option-name`.
108+
* Argument and option names can be given in either [camelCase or dash-case](guide/glossary#case-types).
109+
`--myOptionName` is equivalent to `--my-option-name`.
94110

95111
### Boolean options
96112

97113
Boolean options have two forms: `--this-option` sets the flag to `true`, `--no-this-option` sets it to `false`.
98114
If neither option is supplied, the flag remains in its default state, as listed in the reference documentation.
99115

100-
101116
### Relative paths
102117

103118
Options that specify files can be given as absolute paths, or as paths relative to the current working directory, which is generally either the workspace or project root.
104119

105120
### Schematics
106121

107-
The [ng generate](cli/generate) and [ng add](cli/add) commands take as an argument the artifact or library to be generated or added to the current project.
122+
The [ng generate](cli/generate) and [ng add](cli/add) commands take, as an argument, the artifact or library to be generated or added to the current project.
108123
In addition to any general options, each artifact or library defines its own options in a *schematic*.
109124
Schematic options are supplied to the command in the same format as immediate command options.
125+
126+
<!-- links -->
127+
128+
<!-- external links -->
129+
130+
<!-- end links -->
131+
132+
@reviewed 2022-02-28

aio/content/cli/usage-analytics-gathering.md

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,27 +20,43 @@ This ID is a string that looks like `UA-123456-12`.
2020
You can choose to use a descriptive string as the key value, or be assigned a random key when you run the CLI command.
2121
For example, the following command adds a configuration key named "tracking".
2222

23-
<code-example language="sh">
23+
<code-example format="shell" language="shell">
24+
2425
ng config --global cli.analyticsSharing.tracking UA-123456-12
26+
2527
</code-example>
2628

2729
To turn off this feature, run the following command:
2830

29-
<code-example language="sh">
31+
<code-example format="shell" language="shell">
32+
3033
ng config --global cli.analyticsSharing undefined
34+
3135
</code-example>
3236

3337
## Per user tracking
3438

3539
You can add a custom user ID to the global configuration, in order to identify unique usage of commands and flags.
3640
If that user enables CLI analytics for their own project, your analytics display tracks and labels their individual usage.
3741

38-
<code-example language="sh">
42+
<code-example format="shell" language="shell">
43+
3944
ng config --global cli.analyticsSharing.uuid SOME_USER_NAME
45+
4046
</code-example>
4147

4248
To generate a new random user ID, run the following command:
4349

44-
<code-example language="sh">
50+
<code-example format="shell" language="shell">
51+
4552
ng config --global cli.analyticsSharing.uuid ""
53+
4654
</code-example>
55+
56+
<!-- links -->
57+
58+
<!-- external links -->
59+
60+
<!-- end links -->
61+
62+
@reviewed 2022-02-28

aio/content/errors/NG0100.md

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,36 @@
44
@shortDescription Expression has changed after it was checked
55

66
@description
7-
Angular throws an `ExpressionChangedAfterItHasBeenCheckedError` when an expression value has been changed after change detection has completed. Angular only throws this error in development mode.
87

9-
In development mode, Angular performs an additional check after each change detection run, to ensure the bindings haven’t changed. This catches errors where the view is left in an inconsistent state. This can occur, for example, if a method or getter returns a different value each time it is called, or if a child component changes values on its parent. If either of these occur, this is a sign that change detection is not stabilized. Angular throws the error to ensure data is always reflected correctly in the view, which prevents erratic UI behavior or a possible infinite loop.
8+
Angular throws an `ExpressionChangedAfterItHasBeenCheckedError` when an expression value has been changed after change detection has completed.
9+
Angular only throws this error in development mode.
1010

11-
This error commonly occurs when you’ve added template expressions or begun to implement lifecycle hooks like `ngAfterViewInit` or `ngOnChanges`. It is also common when dealing with loading status and asynchronous operations, or a child component changes its parent bindings.
11+
In development mode, Angular performs an additional check after each change detection run, to ensure the bindings haven't changed.
12+
This catches errors where the view is left in an inconsistent state.
13+
This can occur, for example, if a method or getter returns a different value each time it is called, or if a child component changes values on its parent.
14+
If either of these occur, this is a sign that change detection is not stabilized
15+
Angular throws the error to ensure data is always reflected correctly in the view, which prevents erratic UI behavior or a possible infinite loop.
16+
17+
This error commonly occurs when you've added template expressions or have begun to implement lifecycle hooks like `ngAfterViewInit` or `ngOnChanges`.
18+
It is also common when dealing with loading status and asynchronous operations, or when a child component changes its parent bindings.
1219

1320
@debugging
14-
The [source maps](https://developer.mozilla.org/en-US/docs/Tools/Debugger/How_to/Use_a_source_map) generated by the CLI are very useful when debugging. Navigate up the call stack until you find a template expression where the value displayed in the error has changed.
1521

16-
Ensure that there are no changes to the bindings in the template after change detection is run. This often means refactoring to use the correct [component lifecycle hook](guide/lifecycle-hooks) for your use case. If the issue exists within `ngAfterViewInit`, the recommended solution is to use a constructor or `ngOnInit` to set initial values, or use `ngAfterContentInit` for other value bindings.
22+
The [source maps](https://developer.mozilla.org/docs/Tools/Debugger/How_to/Use_a_source_map) generated by the CLI are very useful when debugging.
23+
Navigate up the call stack until you find a template expression where the value displayed in the error has changed.
24+
25+
Ensure that there are no changes to the bindings in the template after change detection is run.
26+
This often means refactoring to use the correct [component lifecycle hook](guide/lifecycle-hooks) for your use case.
27+
If the issue exists within `ngAfterViewInit`, the recommended solution is to use a constructor or `ngOnInit` to set initial values, or use `ngAfterContentInit` for other value bindings.
1728

1829
If you are binding to methods in the view, ensure that the invocation does not update any of the other bindings in the template.
1930

20-
Read more about which solution is right for you in ['Everything you need to know about the "ExpressionChangedAfterItHasBeenCheckedError" error'](https://indepth.dev/posts/1001/everything-you-need-to-know-about-the-expressionchangedafterithasbeencheckederror-error) and why this is useful at ['Angular Debugging "Expression has changed after it was checked": Simple Explanation (and Fix)'](https://blog.angular-university.io/angular-debugging/).
31+
Read more about which solution is right for you in ['Everything you need to know about the "ExpressionChangedAfterItHasBeenCheckedError" error'](https://indepth.dev/posts/1001/everything-you-need-to-know-about-the-expressionchangedafterithasbeencheckederror-error) and why this is useful at ['Angular Debugging "Expression has changed after it was checked": Simple Explanation (and Fix)'](https://blog.angular-university.io/angular-debugging).
32+
33+
<!-- links -->
34+
35+
<!-- external links -->
36+
37+
<!-- end links -->
38+
39+
@reviewed 2022-02-28

aio/content/errors/NG0200.md

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,23 @@
44
@shortDescription Circular dependency in DI detected while instantiating a provider
55

66
@description
7-
A cyclic dependency exists when a [dependency of a service](guide/hierarchical-dependency-injection) directly or indirectly depends on the service itself. For example, if `UserService` depends on `EmployeeService`, which also depends on `UserService`. Angular will have to instantiate `EmployeeService` to create `UserService`, which depends on `UserService`, itself.
7+
8+
A cyclic dependency exists when a [dependency of a service](guide/hierarchical-dependency-injection) directly or indirectly depends on the service itself.
9+
For example, if `UserService` depends on `EmployeeService`, which also depends on `UserService`.
10+
Angular will have to instantiate `EmployeeService` to create `UserService`, which depends on `UserService`, itself.
811

912
@debugging
10-
Use the call stack to determine where the cyclical dependency exists. You will be able to see if any child dependencies rely on the original file by [mapping out](guide/dependency-injection-in-action) the component, module, or service’s dependencies and identify the loop causing the problem.
1113

12-
Break this loop (or circle) of dependency to resolve this error. This most commonly means removing or refactoring the dependencies to not be reliant on one another.
14+
Use the call stack to determine where the cyclical dependency exists.
15+
You will be able to see if any child dependencies rely on the original file by [mapping out](guide/dependency-injection-in-action) the component, module, or service's dependencies, and identifying the loop causing the problem.
16+
17+
Break this loop \(or circle\) of dependency to resolve this error.
18+
This most commonly means removing or refactoring the dependencies to not be reliant on one another.
19+
20+
<!-- links -->
21+
22+
<!-- external links -->
23+
24+
<!-- end links -->
25+
26+
@reviewed 2022-02-28

aio/content/errors/NG0201.md

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,30 @@
44
@shortDescription No provider for {token} found!
55

66
@description
7+
78
You see this error when you try to inject a service but have not declared a corresponding provider. A provider is a mapping that supplies a value that you can inject into the constructor of a class in your application.
89

910
Read more on providers in our [Dependency Injection guide](guide/dependency-injection).
1011

1112
@debugging
12-
Work backwards from the object where the error states that a [provider](guide/architecture-services) is missing: `No provider for ${this}!`. This is commonly thrown in [services](tutorial/toh-pt4), which require non-existing providers.
13+
14+
Work backwards from the object where the error states that a [provider](guide/architecture-services) is missing: `No provider for ${this}!`.
15+
This is commonly thrown in [services](tutorial/toh-pt4), which require non-existing providers.
1316

1417
To fix the error ensure that your service is registered in the list of providers of an `NgModule` or has the `@Injectable` decorator with a `providedIn` property at top.
1518

1619
The most common solution is to add a provider in `@Injectable` using `providedIn`:
1720

18-
```typescript
19-
@Injectable({ providedIn: 'app' })
20-
```
21+
<code-example format="typescript" language="typescript">
22+
23+
&commat;Injectable({ providedIn: 'app' })
24+
25+
</code-example>
26+
27+
<!-- links -->
28+
29+
<!-- external links -->
30+
31+
<!-- end links -->
32+
33+
@reviewed 2022-02-28

0 commit comments

Comments
 (0)