From 9386a6606f081811614344fe8d55d349ff30f699 Mon Sep 17 00:00:00 2001 From: Patrice Chalin Date: Fri, 10 Mar 2017 16:05:33 -0800 Subject: [PATCH] docs(structural-directives): move ng-container section later in page (#3367) * docs(structural-directives): move ng-container section later in page See https://github.com/angular/angular.io/pull/3345#issuecomment-285511144. No changes were done to the `` section prose. --- .../latest/guide/structural-directives.jade | 445 +++++++++--------- 1 file changed, 223 insertions(+), 222 deletions(-) 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 `