@@ -31,11 +31,11 @@ <h1>Template Syntax</h1>
3131</ div >
3232< br >
3333< a href ="#star-prefix "> * prefix and <template></ a > < br >
34- < a href ="#local -vars "> Template local variables</ a > < br >
34+ < a href ="#ref -vars "> Template reference variables</ a > < br >
3535< a href ="#inputs-and-outputs "> Inputs and outputs</ a > < br >
3636< a href ="#pipes "> Pipes</ a > < br >
3737< a href ="#safe-navigation-operator "> Safe navigation operator < i > ?.</ i > </ a > < br >
38- <!--< a href="#enums">Enums</a><br>-- >
38+ < a href ="#enums "> Enums</ a > < br >
3939
4040<!-- Interpolation and expressions -->
4141< hr > < h2 id ="interpolation "> Interpolation</ h2 >
105105<!-- #docregion event-binding-syntax-1 -->
106106< button (click) = "onSave() "> Save</ button >
107107< hero-detail (deleteRequest) ="deleteHero() "> </ hero-detail >
108- < div (myClick) ="clickity =$event "> click me</ div >
108+ < div (myClick) ="clicked =$event "> click me</ div >
109109<!-- #enddocregion event-binding-syntax-1 -->
110- {{clickity }}
110+ {{clicked }}
111111< br > < br >
112112
113113< div >
@@ -184,15 +184,14 @@ <h3>
184184<!-- #enddocregion property-binding-5 -->
185185
186186<!-- #docregion property-binding-6 -->
187- <!-- BAD! HeroDetailComponent.hero expects a Hero object,
188- not the string "currentHero".
189-
190- <hero-detail hero="currentHero"></hero-detail> -->
187+ <!-- ERROR: HeroDetailComponent.hero expects a
188+ Hero object, not the string "currentHero" -->
191189<!-- #enddocregion property-binding-6 -->
192-
193- <!-- In checked mode, uncommenting the hero-detail above causes this:
194- EXCEPTION: type 'String' is not a subtype of type 'Hero' of 'value'. -->
195-
190+ < div *ngIf ="false ">
191+ <!-- #docregion property-binding-6 -->
192+ < hero-detail hero ="currentHero "> </ hero-detail >
193+ <!-- #enddocregion property-binding-6 -->
194+ </ div >
196195<!-- #docregion property-binding-7 -->
197196< hero-detail prefix ="You are my " [hero] ="currentHero "> </ hero-detail >
198197<!-- #enddocregion property-binding-7 -->
202201Property bound: < img [src] ="heroImageUrl ">
203202
204203< div > The interpolated title is {{title}}</ div >
205- < div [textContent ] ="'The [textContent ] title is '+title "> </ div >
204+ < div [innerHTML ] ="'The [innerHTML ] title is '+title "> </ div >
206205<!-- #enddocregion property-binding-vs-interpolation -->
207206
208207< a class ="to-toc " href ="#toc "> top</ a >
258257<!-- #docregion class-binding-2 -->
259258<!-- reset/override all class names with a binding -->
260259< div class ="bad curly special "
261- [class] ="badCurly "> Bad curly</ div >
262- < p > < b > Note:</ b > "Bad curly" should be smaller but isn't, due to
263- < a href ="http://github.com/angular/angular/issues/6901 "> issue #6901</ a > .</ p >
260+ [className] ="badCurly "> Bad curly</ div >
264261<!-- #enddocregion class-binding-2 -->
265262
266263<!-- #docregion class-binding-3 -->
@@ -374,15 +371,15 @@ <h3>Result: {{currentHero.firstName}}</h3>
374371< br >
375372<!-- #docregion NgModel-3 -->
376373< input
377- [ngModel] ="currentHero.firstName "
378- (ngModelChange) ="currentHero.firstName=$event ">
374+ [ngModel] ="currentHero.firstName "
375+ (ngModelChange) ="currentHero.firstName=$event ">
379376<!-- #enddocregion NgModel-3 -->
380377(ngModelChange) = "...firstName=$event"
381378< br >
382379<!-- #docregion NgModel-4 -->
383380< input
384- [ngModel] ="currentHero.firstName "
385- (ngModelChange) ="setUpperCaseFirstName($event) ">
381+ [ngModel] ="currentHero.firstName "
382+ (ngModelChange) ="setUpperCaseFirstName($event) ">
386383<!-- #enddocregion NgModel-4 -->
387384(ngModelChange) = "setUpperCaseFirstName($event)"
388385< br >
@@ -443,7 +440,7 @@ <h3>Use setStyles() - CSS property names</h3>
443440<!-- #enddocregion NgIf-1 -->
444441
445442<!-- #docregion NgIf-2 -->
446- <!-- not displayed because nullHero is false.
443+ <!-- because of the ngIf guard
447444 `nullHero.firstName` never has a chance to fail -->
448445< div *ngIf ="nullHero != null "> Hello, {{nullHero.firstName}}</ div >
449446
@@ -487,33 +484,33 @@ <h3>Use setStyles() - CSS property names</h3>
487484</ fieldset >
488485
489486< div class ="toe ">
490- < div *ngIf ="toeChoice == null "> Pick a toe</ div >
491- < div *ngIf ="toeChoice != null ">
492- You picked ...
493- <!-- #docregion NgSwitch, NgSwitch-expanded -->
494- < span [ngSwitch] ="toeChoice ">
487+ < div *ngIf ="toeChoice == null "> Pick a toe</ div >
488+ < div *ngIf ="toeChoice != null ">
489+ You picked ...
490+ <!-- #docregion NgSwitch, NgSwitch-expanded -->
491+ < span [ngSwitch] ="toeChoice ">
495492 <!-- #enddocregion NgSwitch -->
496493
497- <!-- with *NgSwitch -->
498- <!-- #docregion NgSwitch -->
499- < span *ngSwitchWhen ="'Eenie' "> Eenie</ span >
500- < span *ngSwitchWhen ="'Meanie' "> Meanie</ span >
501- < span *ngSwitchWhen ="'Miney' "> Miney</ span >
502- < span *ngSwitchWhen ="'Moe' "> Moe</ span >
503- < span *ngSwitchDefault > other</ span >
504- <!-- #enddocregion NgSwitch -->
505-
506- <!-- with <template> -->
507- < template ngSwitchWhen =" Eenie "> < span > Eenie</ span > </ template >
508- < template ngSwitchWhen =" Meanie "> < span > Meanie</ span > </ template >
509- < template ngSwitchWhen =" Miney "> < span > Miney</ span > </ template >
510- < template ngSwitchWhen =" Moe "> < span > Moe</ span > </ template >
511- < template ngSwitchDefault > < span > other</ span > </ template >
494+ <!-- with *NgSwitch -->
495+ <!-- #docregion NgSwitch -->
496+ < span *ngSwitchWhen ="'Eenie' "> Eenie</ span >
497+ < span *ngSwitchWhen ="'Meanie' "> Meanie</ span >
498+ < span *ngSwitchWhen ="'Miney' "> Miney</ span >
499+ < span *ngSwitchWhen ="'Moe' "> Moe</ span >
500+ < span *ngSwitchDefault > other</ span >
501+ <!-- #enddocregion NgSwitch -->
502+
503+ <!-- with <template> -->
504+ < template [ ngSwitchWhen] =" ' Eenie' "> < span > Eenie</ span > </ template >
505+ < template [ ngSwitchWhen] =" ' Meanie' "> < span > Meanie</ span > </ template >
506+ < template [ ngSwitchWhen] =" ' Miney' "> < span > Miney</ span > </ template >
507+ < template [ ngSwitchWhen] =" ' Moe' "> < span > Moe</ span > </ template >
508+ < template ngSwitchDefault > < span > other</ span > </ template >
512509
513510 <!-- #docregion NgSwitch -->
514- </ span >
515- <!-- #enddocregion NgSwitch, NgSwitch-expanded -->
516- </ div >
511+ </ span >
512+ <!-- #enddocregion NgSwitch, NgSwitch-expanded -->
513+ </ div >
517514</ div >
518515
519516< a class ="to-toc " href ="#toc "> top</ a >
@@ -620,7 +617,7 @@ <h3>*ngIf expansion</h3>
620617< p > < i > expand to <template></ i > </ p >
621618<!-- #docregion Template-2 -->
622619< template [ngIf] ="currentHero != null ">
623- < hero-detail [hero] ="currentHero "> </ hero-detail >
620+ < hero-detail [hero] ="currentHero "> </ hero-detail >
624621</ template >
625622<!-- #enddocregion Template-2 -->
626623
@@ -644,15 +641,15 @@ <h3>*ngFor expansion</h3>
644641 <!-- ngFor w/ hero-detail Component inside a template element -->
645642 <!-- #docregion Template-4 -->
646643 < template ngFor let-hero [ngForOf] ="heroes " [ngForTrackBy] ="trackByHeroes ">
647- < hero-detail [hero] ="hero "> </ hero-detail >
644+ < hero-detail [hero] ="hero "> </ hero-detail >
648645 </ template >
649646 <!-- #enddocregion Template-4 -->
650647</ div >
651648
652649< a class ="to-toc " href ="#toc "> top</ a >
653650
654- <!-- template local variable -->
655- < hr > < h2 id ="local -vars "> Template local variables</ h2 >
651+ <!-- template reference variable -->
652+ < hr > < h2 id ="ref -vars "> Template reference variables</ h2 >
656653
657654<!-- #docregion ref-phone -->
658655<!-- phone refers to the input element; pass its `value` to an event handler -->
@@ -672,7 +669,7 @@ <h4>Example Form</h4>
672669 < div class ="form-group ">
673670 < label for ="name "> Name</ label >
674671 < input class ="form-control " required ngControl ="firstName "
675- [(ngModel)] ="currentHero.firstName ">
672+ [(ngModel)] ="currentHero.firstName ">
676673 </ div >
677674<!-- #docregion ref-form-a -->
678675 < button type ="submit " [disabled] ="!theForm.form.valid "> Submit</ button >
@@ -682,7 +679,7 @@ <h4>Example Form</h4>
682679< br > < br >
683680
684681<!-- btn refers to the button element; show its disabled state -->
685- < button #btn disabled [textContent ] ="'disabled by attribute: ' + btn.disabled.toString() "> </ button >
682+ < button #btn disabled [innerHTML ] ="'disabled by attribute: ' + btn.disabled.toString() "> </ button >
686683
687684< a class ="to-toc " href ="#toc "> top</ a >
688685
@@ -708,13 +705,15 @@ <h4>Example Form</h4>
708705< hr > < h2 id ="pipes "> Pipes</ h2 >
709706
710707<!-- #docregion pipes-1 -->
711- <!-- Force title to uppercase -->
712- < div > {{ title | uppercase }}</ div >
708+ < div > Title through uppercase pipe: {{title | uppercase}}</ div >
713709<!-- #enddocregion pipes-1 -->
714710
715711<!-- #docregion pipes-2 -->
716- <!-- Pipe chaining: force title to uppercase, then to lowercase -->
717- < div > {{ title | uppercase | lowercase }}</ div >
712+ <!-- Pipe chaining: convert title to uppercase, then to lowercase -->
713+ < div >
714+ Title through a pipe chain:
715+ {{title | uppercase | lowercase}}
716+ </ div >
718717<!-- #enddocregion pipes-2 -->
719718
720719<!-- #docregion pipes-3 -->
@@ -723,16 +722,14 @@ <h4>Example Form</h4>
723722<!-- #enddocregion pipes-3 -->
724723
725724<!-- #docregion pipes-json -->
726- <!-- We don't suggest using json for debugging; you'd probably use toString() instead.
727- Is there a good use for the json pipe in Dart? -->
728- <!--<div>{{currentHero | json}}</div>-->
725+ < div > {{currentHero}}</ div >
729726<!-- #enddocregion pipes-json -->
730727
731728< div > Birthdate: {{(currentHero?.birthdate | date:'longDate') | uppercase}}</ div >
732729
733730< div >
734731 <!-- pipe price to USD and display the $ symbol -->
735- < label > Price: </ label > {{product['price'] | currency:'$' }}
732+ < label > Price: </ label > {{product['price'] | currency:'USD':false }}
736733</ div >
737734
738735< a class ="to-toc " href ="#toc "> top</ a >
@@ -742,7 +739,7 @@ <h4>Example Form</h4>
742739
743740< div >
744741 <!-- #docregion safe-1 -->
745- The title is {{ title }}
742+ The title is {{title}}
746743 <!-- #enddocregion safe-1 -->
747744</ div >
748745
@@ -759,11 +756,10 @@ <h4>Example Form</h4>
759756</ div >
760757
761758
762-
763759<!--
764760The null hero's name is {{nullHero.firstName}}
765761
766- See console log:
762+ See console log:
767763 EXCEPTION: The null object does not have a getter 'firstName'.
768764-->
769765
@@ -784,19 +780,16 @@ <h4>Example Form</h4>
784780
785781< a class ="to-toc " href ="#toc "> top</ a >
786782
787- <!-- Todo : discuss this in the Style binding section -->
783+ <!-- TODO : discuss this in the Style binding section -->
788784<!-- enums in bindings -->
789-
790785< hr > < h2 id ="enums "> Enums in binding</ h2 >
791786
792- <!--<p>The name of the Color.red enum is {{color}}</p>-->
793- < p > The current color number is {{color}}</ p >
794- < p > < button [style.color] ="color.toString() " (click) ="colorToggle() "> Enum Toggle</ button >
795-
796- < a class ="to-toc " href ="#toc "> top</ a >
797-
798- <!-- #docregion my-first-app -->
799- < h3 > My First Angular Application</ h3 >
800- <!-- #enddocregion my-first-app -->
787+ < p >
788+ <!-- #docregion enums -->
789+ The name of the Color.red enum is {{colorRed}}.< br >
790+ The current color is {{color}} and its index is {{color.index}}.< br >
791+ < button [style.color] ="color.toString() " (click) ="colorToggle() "> Enum Toggle</ button >
792+ <!-- #enddocregion enums -->
793+ </ p >
801794
802795< a class ="to-toc " href ="#toc "> top</ a >
0 commit comments