@@ -108,8 +108,7 @@ class AppComponent implements OnInit, AfterViewInit {
108
108
109
109
bool onSave ([UIEvent event = null ]) {
110
110
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 }.' : '' ;
113
112
alerter ('Saved. $evtMsg ' );
114
113
return false ;
115
114
}
@@ -126,8 +125,12 @@ class AppComponent implements OnInit, AfterViewInit {
126
125
}
127
126
128
127
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);
131
134
}
132
135
133
136
Map <String , bool > _previousClasses = {};
@@ -140,24 +143,38 @@ class AppComponent implements OnInit, AfterViewInit {
140
143
};
141
144
// #docregion setClasses
142
145
// 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;
145
148
_previousClasses = classes;
146
149
// #enddocregion setClasses
147
150
return classes;
148
151
}
149
152
// #enddocregion setClasses
150
153
151
154
// #docregion setStyles
152
- Map setStyles () {
153
- return {
155
+ Map < String , String > setStyles () {
156
+ return < String , String > {
154
157
'font-style' : canSave ? 'italic' : 'normal' , // italic
155
158
'font-weight' : ! isUnchanged ? 'bold' : 'normal' , // normal
156
159
'font-size' : isSpecial ? '24px' : '8px' // 24px
157
160
};
158
161
}
159
162
// #enddocregion setStyles
160
163
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
+
161
178
String title = 'Template Syntax' ;
162
179
String toeChoice;
163
180
String toeChooser (Element picker) {
@@ -187,13 +204,16 @@ class AppComponent implements OnInit, AfterViewInit {
187
204
int heroesNoTrackByChangeCount = 0 ;
188
205
int heroesWithTrackByChangeCount = 0 ;
189
206
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;
192
211
193
212
void _detectNgForTrackByEffects () {
194
213
/// Converts [viewChildren] to a list of [Element] .
195
214
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 >;
197
217
198
218
{
199
219
// Updates 'without TrackBy' statistics.
0 commit comments