@@ -108,8 +108,7 @@ class AppComponent implements OnInit, AfterViewInit {
108108
109109 bool onSave ([UIEvent event = null ]) {
110110 HtmlElement el = event? .target;
111- var evtMsg =
112- event != null ? ' Event target is ${el .innerHtml }.' : '' ;
111+ var evtMsg = event != null ? ' Event target is ${el .innerHtml }.' : '' ;
113112 alerter ('Saved. $evtMsg ' );
114113 return false ;
115114 }
@@ -126,8 +125,12 @@ class AppComponent implements OnInit, AfterViewInit {
126125 }
127126
128127 String getStyles (Element el) {
129- var showStyles = setStyles ();
130- return JSON .encode (showStyles);
128+ final style = el.style;
129+ final Map styles = < String , String > {};
130+ for (var i = 0 ; i < style.length; i++ ) {
131+ styles[style.item (i)] = style.getPropertyValue (style.item (i));
132+ }
133+ return JSON .encode (styles);
131134 }
132135
133136 Map <String , bool > _previousClasses = {};
@@ -140,24 +143,38 @@ class AppComponent implements OnInit, AfterViewInit {
140143 };
141144 // #docregion setClasses
142145 // compensate for DevMode (sigh)
143- if (JSON .encode (_previousClasses) ==
144- JSON . encode (classes)) return _previousClasses;
146+ if (JSON .encode (_previousClasses) == JSON . encode (classes))
147+ return _previousClasses;
145148 _previousClasses = classes;
146149 // #enddocregion setClasses
147150 return classes;
148151 }
149152 // #enddocregion setClasses
150153
151154 // #docregion setStyles
152- Map setStyles () {
153- return {
155+ Map < String , String > setStyles () {
156+ return < String , String > {
154157 'font-style' : canSave ? 'italic' : 'normal' , // italic
155158 'font-weight' : ! isUnchanged ? 'bold' : 'normal' , // normal
156159 'font-size' : isSpecial ? '24px' : '8px' // 24px
157160 };
158161 }
159162 // #enddocregion setStyles
160163
164+ // #docregion NgStyle
165+ bool isItalic = false ;
166+ bool isBold = false ;
167+ String fontSize = 'large' ;
168+
169+ Map <String , String > setStyle () {
170+ return {
171+ 'font-style' : isItalic ? 'italic' : 'normal' ,
172+ 'font-weight' : isBold ? 'bold' : 'normal' ,
173+ 'font-size' : fontSize
174+ };
175+ }
176+ // #enddocregion NgStyle
177+
161178 String title = 'Template Syntax' ;
162179 String toeChoice;
163180 String toeChooser (Element picker) {
@@ -187,13 +204,16 @@ class AppComponent implements OnInit, AfterViewInit {
187204 int heroesNoTrackByChangeCount = 0 ;
188205 int heroesWithTrackByChangeCount = 0 ;
189206
190- @ViewChildren ('noTrackBy' ) QueryList <ElementRef > childrenNoTrackBy;
191- @ViewChildren ('withTrackBy' ) QueryList <ElementRef > childrenWithTrackBy;
207+ @ViewChildren ('noTrackBy' )
208+ QueryList <ElementRef > childrenNoTrackBy;
209+ @ViewChildren ('withTrackBy' )
210+ QueryList <ElementRef > childrenWithTrackBy;
192211
193212 void _detectNgForTrackByEffects () {
194213 /// Converts [viewChildren] to a list of [Element] .
195214 List <Element > _extractChildren (QueryList <ElementRef > viewChildren) =>
196- viewChildren.toList ()[0 ].nativeElement.children.toList () as List <Element >;
215+ viewChildren.toList ()[0 ].nativeElement.children.toList ()
216+ as List <Element >;
197217
198218 {
199219 // Updates 'without TrackBy' statistics.
0 commit comments