-
Notifications
You must be signed in to change notification settings - Fork 24.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
docs: make structural directives guide generic #44895
docs: make structural directives guide generic #44895
Conversation
@@ -110,15 +110,20 @@ <h2 id="ngFor">NgFor</h2> | |||
|
|||
<p class="code"><div *ngFor="let hero of heroes; let i=index; let odd=odd; trackBy: trackById" [class.odd]="odd"></p> | |||
<!--#docregion inside-ngfor --> | |||
<div *ngFor="let hero of heroes; let i=index; let odd=odd; trackBy: trackById" [class.odd]="odd"> | |||
<div |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I split this and the one below because in the UI the lines were easily wrapped, this should marginally help
@@ -240,15 +240,12 @@ then uses this template repeatedly to create a new set of elements and bindings | |||
in the list. | |||
For more information about shorthand, see the [Structural Directives](guide/structural-directives#shorthand) guide. | |||
|
|||
{@a one-per-element} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this section isn't really explaining clearly the one-per-element topic, a section just for that has been added in the structural directives guide.
|
||
For more information about `NgFor` see the [NgForOf API reference](api/common/NgForOf). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this guide already talks about the NgFor
in the previous sections, so putting here the link seems to me pretty unnecessary
|
||
<div class="alert is-helpful"> | ||
|
||
For the example application that this page describes, see the <live-example></live-example>. | ||
|
||
</div> | ||
|
||
For more information on Angular's built-in structural directives, such as `NgIf`, `NgForOf`, and `NgSwitch`, see [Built-in directives](guide/built-in-directives). | ||
## What they are |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
may not be the best section name ever.... 馃槗
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could eliminate the need for this header by moving lines 13-15 to above the example.
Because that's the obvious place to see a description of the subject you're about to discuss further in the topic, it doesn't need a heading to introduce it.
{@a one-per-element} | ||
## One structural directive per element |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This section was removed in PR #40015 (which by the way is the PR that made this guide non-generic)
I am not a big fan of moving changes back and forth but I believe the way this was refactored really just lacks clarity and makes things much more difficult to understand.
I put back the section with one or two minor tweaks as I thought it was already well written, if we want I can rewrite this with my own words too.
@@ -295,12 +309,14 @@ The value of the property can be either a general type-narrowing function based | |||
For example, consider the following structural directive that takes the result of a template expression as an input: | |||
|
|||
<code-example language="ts" header="IfLoadedDirective"> | |||
export type Loaded<T> = { type: 'loaded', data: T }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
### Creating template fragments with `<ng-template>` | ||
|
||
Angular's `<ng-template>` element defines a template that doesn't render anything by default. | ||
With `<ng-template>`, you can render the content manually for full control over how the content displays. | ||
|
||
If there is no structural directive and you wrap some elements in an `<ng-template>`, those elements disappear. | ||
In the following example, Angular does not render the middle "Hip!" in the phrase "Hip! Hip! Hooray!" because of the surrounding `<ng-template>`. | ||
|
||
<code-example path="structural-directives/src/app/app.component.html" header="src/app/app.component.html (template-tag)" region="template-tag"></code-example> | ||
|
||
<div class="lightbox"> | ||
<img src='generated/images/guide/structural-directives/template-rendering.png' alt="template tag rendering"> | ||
</div> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this should sit in the structural directives guide, I changed this (see line 70 above) to a quick alert redirecting to the ng-template api docs (in which I also added a shortened alert with the example shown here)
1278b26
to
a886017
Compare
I just noticed that I am applying the fix for: #40739 in that issue it is suggested to move the example to a doc region, my fixing it here shouldn't prevent that from being done afterwards anyways (maybe as a follow-up PR, as I mentioned in the PR's description the section should also be moved elsewhere, maybe both things can be done in the same PR) (PS: I volunteer myself for that by the way 馃槃) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome work @dario-piotrowicz 馃憤
I've left a few comments, please let me know what you think.
Once the feedback is addressed, we'd need a docs team review of the content as well.
Thank you.
@AndrewKushnir thanks a lot for your awesome reviewing! 馃槏 (and sorry for making you put that many comments 馃檹 馃槗) I've addressed your comments, please have another look 馃檪 |
Added @TeriGlover for editing review. |
Thanks for the nice reviewing @atscott 馃檪, all addressed 馃憤 |
331b00c
to
46800ff
Compare
Hi @TeriGlover, any change you could have a look at this PR? 馃檱 馃檹 馃檱 |
46800ff
to
fcda1d0
Compare
d3deed3
to
37d041b
Compare
@bob-watson could you please help with the review for this PR from docs perspective (Andrew and myself verified that the context is correct from the technical perspective)? Thank you. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the "what they are" heading really bugs you, I offered an alternative.
Other than that, it seems reasonable after a quick glance.
|
||
<div class="alert is-helpful"> | ||
|
||
For the example application that this page describes, see the <live-example></live-example>. | ||
|
||
</div> | ||
|
||
For more information on Angular's built-in structural directives, such as `NgIf`, `NgForOf`, and `NgSwitch`, see [Built-in directives](guide/built-in-directives). | ||
## What they are |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could eliminate the need for this header by moving lines 13-15 to above the example.
Because that's the obvious place to see a description of the subject you're about to discuss further in the topic, it doesn't need a heading to introduce it.
tweak the current structural directives guide (currently mainly targeted at the creation of custom structural directives) so that is more generic and a point of reference for structural directives in general this also includes the re-addition of the one-per-element section removed in PR angular#40015 resolves angular#44786
37d041b
to
dc1641e
Compare
Merge-assistance: the approvals got reset after a fixup commit. I've reviewed and approved it, so this PR is ready for merge. |
This PR was merged into the repository by commit c8086b7. |
tweak the current structural directives guide (currently mainly targeted at the creation of custom structural directives) so that is more generic and a point of reference for structural directives in general this also includes the re-addition of the one-per-element section removed in PR #40015 resolves #44786 PR Close #44895
tweak the current structural directives guide (currently mainly targeted at the creation of custom structural directives) so that is more generic and a point of reference for structural directives in general this also includes the re-addition of the one-per-element section removed in PR #40015 resolves #44786 PR Close #44895
amend the aio glossary using as the structural-directives guide link's title the outdated heading of that guide (changed in PR angular#44895)
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
tweak the current structural directives guide (currently mainly targeted
at the creation of custom structural directives) so that is more generic
and a point of reference for structural directives in general
this also includes the re-addition of the one-per-element section
removed in PR #40015
resolves #44786
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
Issue Number: #44786
Does this PR introduce a breaking change?
Other information
@AndrewKushnir 馃檪馃憤
Before & After:
Before:
After:
The "Improving template type checking for custom directives" section should be moved to a different guide, I figured I could keep things cleared by moving it away from the page in a follow-up PR
This partially undoes changes made in PR docs: rewrite structural directives聽#40015