diff --git a/public/docs/ts/latest/guide/structural-directives.jade b/public/docs/ts/latest/guide/structural-directives.jade index 3b19546c36..fc84905169 100644 --- a/public/docs/ts/latest/guide/structural-directives.jade +++ b/public/docs/ts/latest/guide/structural-directives.jade @@ -14,7 +14,6 @@ style. - [What are structural directives?](#definition) - [*NgIf* case study](#ngIf) - - [Group sibling elements with <ng-container>](#ng-container) - [The asterisk (*) prefix](#asterisk) - [Inside *NgFor*](#ngFor) - [microsyntax](#microsyntax) @@ -23,6 +22,7 @@ style. - [Inside the *NgSwitch* directives](#ngSwitch) - [Prefer the (*) prefix](#prefer-asterisk) - [The <template> element](#template) + - [Group sibling elements with <ng-container>](#ng-container) - [Write a structural directive](#unless) Try the . @@ -157,6 +157,226 @@ figure.image-display Before applying a structural directive, you might want to pause for a moment to consider the consequences of adding and removing elements and of creating and destroying components. +a#asterisk +.l-main-section +:marked + ## The asterisk (*) prefix + + Surely you noticed the asterisk (*) prefix to the directive name + and wondered why it is necessary and what it does. + + Here is `*ngIf` displaying the hero's name if `hero` exists. + ++makeExcerpt('src/app/app.component.html', 'asterisk', '') + +:marked + The asterisk is "syntactic sugar" for something a bit more complicated. + Internally, Angular desugars it in two stages. + First, it translates the `*ngIf="..."` into a template _attribute_, `template="ngIf ..."`,  like this. + ++makeExcerpt('src/app/app.component.html', 'ngif-template-attr', '') + +:marked + Then it translates the template _attribute_ into a template _element_, wrapped around the host element, like this. + ++makeExcerpt('src/app/app.component.html', 'ngif-template', '') + +:marked + * The `*ngIf` directive moved to the `