Skip to content

Commit 4bcbac1

Browse files
SkyZeroZxAndrewKushnir
authored andcommitted
docs: Replace ngIf programmatic rendering to control flow (angular#64301)
PR Close angular#64301
1 parent cbaf690 commit 4bcbac1

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

adev/src/content/guide/components/programmatic-rendering.md

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@
22

33
TIP: This guide assumes you've already read the [Essentials Guide](essentials). Read that first if you're new to Angular.
44

5-
In addition to using a component directly in a template, you can also dynamically render components
6-
programmatically. This is helpful for situations when a component is unknown initially (thus can not
5+
In addition to using a component directly in a template, you can also dynamically render components
6+
programmatically. This is helpful for situations when a component is unknown initially (thus can not
77
be referenced in a template directly) and it depends on some conditions.
88

99
There are two main ways to render a component programmatically: in a template using `NgComponentOutlet`,
10-
or in your TypeScript code using `ViewContainerRef`.
10+
or in your TypeScript code using `ViewContainerRef`.
1111

12-
HELPFUL: for lazy-loading use-cases (for example if you want to delay loading of a heavy component), consider
13-
using the built-in [`@defer` feature](/guide/templates/defer) instead. The `@defer` feature allows the code
14-
of any components, directives, and pipes inside the `@defer` block to be extracted into separate JavaScript
12+
HELPFUL: for lazy-loading use-cases (for example if you want to delay loading of a heavy component), consider
13+
using the built-in [`@defer` feature](/guide/templates/defer) instead. The `@defer` feature allows the code
14+
of any components, directives, and pipes inside the `@defer` block to be extracted into separate JavaScript
1515
chunks automatically and loaded only when necessary, based on the configured triggers.
1616

1717
## Using NgComponentOutlet
@@ -103,10 +103,10 @@ In the example above, clicking the "Load content" button results in the followin
103103

104104
## Lazy-loading components
105105

106-
HELPFUL: if you want to lazy-load some components, you may consider using the built-in [`@defer` feature](/guide/templates/defer)
106+
HELPFUL: if you want to lazy-load some components, you may consider using the built-in [`@defer` feature](/guide/templates/defer)
107107
instead.
108108

109-
If your use-case is not covered by the `@defer` feature, you can use either `NgComponentOutlet` or
109+
If your use-case is not covered by the `@defer` feature, you can use either `NgComponentOutlet` or
110110
`ViewContainerRef` with a standard JavaScript [dynamic import](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/import).
111111

112112
```angular-ts
@@ -119,9 +119,11 @@ If your use-case is not covered by the `@defer` feature, you can use either `NgC
119119
</section>
120120
<section>
121121
<h2>Advanced settings</h2>
122-
<button (click)="loadAdvanced()" *ngIf="!advancedSettings">
123-
Load advanced settings
124-
</button>
122+
@if(!advancedSettings) {
123+
<button (click)="loadAdvanced()">
124+
Load advanced settings
125+
</button>
126+
}
125127
<ng-container *ngComponentOutlet="advancedSettings" />
126128
</section>
127129
`

0 commit comments

Comments
 (0)