| 
									
										
										
										
											2016-05-31 18:36:22 -07:00
										 |  |  | /* tslint:disable:member-ordering forin */ | 
					
						
							|  |  |  | // #docplaster
 | 
					
						
							| 
									
										
										
										
											2016-01-10 17:07:19 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-05-03 14:06:32 +02:00
										 |  |  | import { AfterViewInit, Component, ElementRef, OnInit, QueryList, ViewChildren } from '@angular/core'; | 
					
						
							|  |  |  | import { NgForm } from '@angular/common'; | 
					
						
							| 
									
										
										
										
											2015-12-07 13:31:26 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-05-03 14:06:32 +02:00
										 |  |  | import { Hero } from './hero'; | 
					
						
							|  |  |  | import { HeroDetailComponent, BigHeroDetailComponent } from './hero-detail.component'; | 
					
						
							|  |  |  | import { MyClickDirective, MyClickDirective2 } from './my-click.directive'; | 
					
						
							| 
									
										
										
										
											2015-12-07 13:31:26 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  | // Alerter fn: monkey patch during test
 | 
					
						
							| 
									
										
										
										
											2016-05-31 18:36:22 -07:00
										 |  |  | export function alerter(msg?: string) { | 
					
						
							| 
									
										
										
										
											2015-12-07 13:31:26 -08:00
										 |  |  |   window.alert(msg); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | export enum Color {Red, Green, Blue}; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /** | 
					
						
							|  |  |  |  * Giant grab bag of stuff to drive the chapter | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | @Component({ | 
					
						
							|  |  |  |   selector: 'my-app', | 
					
						
							|  |  |  |   templateUrl: 'app/app.component.html', | 
					
						
							|  |  |  |   directives: [ | 
					
						
							|  |  |  |     HeroDetailComponent, BigHeroDetailComponent, | 
					
						
							|  |  |  |     MyClickDirective, MyClickDirective2 | 
					
						
							|  |  |  |   ] | 
					
						
							|  |  |  | }) | 
					
						
							| 
									
										
										
										
											2016-02-06 17:18:26 -08:00
										 |  |  | export class AppComponent implements AfterViewInit, OnInit { | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-05-31 18:36:22 -07:00
										 |  |  |   ngOnInit() { | 
					
						
							| 
									
										
										
										
											2016-02-06 17:18:26 -08:00
										 |  |  |     this.refreshHeroes(); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   ngAfterViewInit() { | 
					
						
							| 
									
										
										
										
											2016-05-03 14:06:32 +02:00
										 |  |  |     this.detectNgForTrackByEffects(); | 
					
						
							| 
									
										
										
										
											2016-02-06 17:18:26 -08:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2015-12-07 13:31:26 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  |   actionName = 'Go for it'; | 
					
						
							|  |  |  |   alert = alerter; | 
					
						
							| 
									
										
										
										
											2016-01-28 16:01:39 -08:00
										 |  |  |   badCurly = 'bad curly'; | 
					
						
							| 
									
										
										
										
											2016-02-17 10:59:14 -08:00
										 |  |  |   classes = 'special'; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-05-31 18:36:22 -07:00
										 |  |  |   callFax(value: string)   {this.alert(`Faxing ${value} ...`); } | 
					
						
							|  |  |  |   callPhone(value: string) {this.alert(`Calling ${value} ...`); } | 
					
						
							| 
									
										
										
										
											2015-12-07 13:31:26 -08:00
										 |  |  |   canSave =  true; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   Color = Color; | 
					
						
							|  |  |  |   color = Color.Red; | 
					
						
							| 
									
										
										
										
											2016-05-31 18:36:22 -07:00
										 |  |  |   colorToggle() {this.color = (this.color === Color.Red) ? Color.Blue : Color.Red; } | 
					
						
							| 
									
										
										
										
											2015-12-07 13:31:26 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  |   currentHero = Hero.MockHeroes[0]; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-05-31 18:36:22 -07:00
										 |  |  |   deleteHero(hero: Hero) { | 
					
						
							|  |  |  |     this.alert('Deleted hero: ' + (hero && hero.firstName)); | 
					
						
							| 
									
										
										
										
											2016-02-17 10:59:14 -08:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2016-05-03 14:06:32 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-05-31 18:36:22 -07:00
										 |  |  |   // #docregion evil-title
 | 
					
						
							|  |  |  |   evilTitle = 'Template <script>alert("evil never sleeps")</script>Syntax'; | 
					
						
							|  |  |  |   // #enddocregion evil-title
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   title = 'Template Syntax'; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-01-10 17:07:19 -08:00
										 |  |  |   // DevMode memoization fields
 | 
					
						
							| 
									
										
										
										
											2016-05-31 18:36:22 -07:00
										 |  |  |   private priorClasses: {}; | 
					
						
							|  |  |  |   private _priorStyles: {}; | 
					
						
							| 
									
										
										
										
											2016-01-10 17:07:19 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-05-31 18:36:22 -07:00
										 |  |  |   getStyles(el: Element) { | 
					
						
							| 
									
										
										
										
											2015-12-07 13:31:26 -08:00
										 |  |  |     let styles = window.getComputedStyle(el); | 
					
						
							|  |  |  |     let showStyles = {}; | 
					
						
							| 
									
										
										
										
											2016-05-31 18:36:22 -07:00
										 |  |  |     for (let p in this.setStyles()) { | 
					
						
							| 
									
										
										
										
											2015-12-07 13:31:26 -08:00
										 |  |  |       showStyles[p] = styles[p]; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     return JSON.stringify(showStyles); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-05-31 18:36:22 -07:00
										 |  |  |   getVal() { return this.val; } | 
					
						
							| 
									
										
										
										
											2015-12-07 13:31:26 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-05-31 18:36:22 -07:00
										 |  |  |   heroes: Hero[]; | 
					
						
							| 
									
										
										
										
											2015-12-07 13:31:26 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  |   // heroImageUrl = 'http://www.wpclipart.com/cartoon/people/hero/hero_silhoutte_T.png';
 | 
					
						
							|  |  |  |   // Public Domain terms of use: http://www.wpclipart.com/terms.html
 | 
					
						
							|  |  |  |   heroImageUrl = 'images/hero.png'; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-05-31 18:36:22 -07:00
										 |  |  |   // iconUrl = 'https://angular.io/resources/images/logos/standard/shield-large.png';
 | 
					
						
							| 
									
										
										
										
											2016-05-25 15:09:45 -07:00
										 |  |  |   clicked = ''; | 
					
						
							|  |  |  |   clickMessage = ''; | 
					
						
							|  |  |  |   clickMessage2 = ''; | 
					
						
							| 
									
										
										
										
											2015-12-07 13:31:26 -08:00
										 |  |  |   iconUrl = 'images/ng-logo.png'; | 
					
						
							|  |  |  |   isActive = false; | 
					
						
							|  |  |  |   isSpecial = true; | 
					
						
							|  |  |  |   isUnchanged = true; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-05-31 18:36:22 -07:00
										 |  |  |   nullHero: Hero = null; // or undefined
 | 
					
						
							| 
									
										
										
										
											2015-12-07 13:31:26 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-05-31 18:36:22 -07:00
										 |  |  |   onCancel(event: KeyboardEvent) { | 
					
						
							|  |  |  |     let evtMsg = event ? ' Event target is ' + (<HTMLElement>event.target).innerHTML : ''; | 
					
						
							|  |  |  |     this.alert('Canceled.' + evtMsg); | 
					
						
							| 
									
										
										
										
											2015-12-07 13:31:26 -08:00
										 |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-05-31 18:36:22 -07:00
										 |  |  |   onClickMe(event: KeyboardEvent) { | 
					
						
							|  |  |  |     let evtMsg = event ? ' Event target class is ' + (<HTMLElement>event.target).className  : ''; | 
					
						
							|  |  |  |     this.alert('Click me.' + evtMsg); | 
					
						
							| 
									
										
										
										
											2015-12-07 13:31:26 -08:00
										 |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-05-31 18:36:22 -07:00
										 |  |  |   onSave(event: KeyboardEvent) { | 
					
						
							|  |  |  |     let evtMsg = event ? ' Event target is ' + (<HTMLElement>event.target).innerText : ''; | 
					
						
							|  |  |  |     this.alert('Saved.' + evtMsg); | 
					
						
							| 
									
										
										
										
											2015-12-07 13:31:26 -08:00
										 |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-05-31 18:36:22 -07:00
										 |  |  |   onSubmit(form: NgForm) { | 
					
						
							| 
									
										
										
										
											2015-12-07 13:31:26 -08:00
										 |  |  |     let evtMsg = form.valid ? | 
					
						
							| 
									
										
										
										
											2016-05-31 18:36:22 -07:00
										 |  |  |       ' Form value is ' + JSON.stringify(form.value) : | 
					
						
							| 
									
										
										
										
											2015-12-07 13:31:26 -08:00
										 |  |  |       ' Form is invalid'; | 
					
						
							| 
									
										
										
										
											2016-05-31 18:36:22 -07:00
										 |  |  |     this.alert('Form submitted.' + evtMsg); | 
					
						
							| 
									
										
										
										
											2015-12-07 13:31:26 -08:00
										 |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   product = { | 
					
						
							|  |  |  |     name: 'frimfram', | 
					
						
							|  |  |  |     price: 42 | 
					
						
							|  |  |  |   }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-02-06 17:18:26 -08:00
										 |  |  |   // #docregion refresh-heroes
 | 
					
						
							|  |  |  |   // update this.heroes with fresh set of cloned heroes
 | 
					
						
							|  |  |  |   refreshHeroes() { | 
					
						
							|  |  |  |     this.heroes = Hero.MockHeroes.map(hero => Hero.clone(hero)); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  |   // #enddocregion refresh-heroes
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   // #docregion same-as-it-ever-was
 | 
					
						
							| 
									
										
										
										
											2016-05-03 14:06:32 +02:00
										 |  |  |   private samenessCount = 5; | 
					
						
							| 
									
										
										
										
											2016-05-31 18:36:22 -07:00
										 |  |  |   moreOfTheSame() { this.samenessCount++; }; | 
					
						
							| 
									
										
										
										
											2016-02-06 17:18:26 -08:00
										 |  |  |   get sameAsItEverWas() { | 
					
						
							| 
									
										
										
										
											2016-05-31 18:36:22 -07:00
										 |  |  |     let result: string[] = Array(this.samenessCount); | 
					
						
							|  |  |  |     for ( let i = result.length; i-- > 0; ) { result[i] = 'same as it ever was ...'; } | 
					
						
							| 
									
										
										
										
											2016-02-06 17:18:26 -08:00
										 |  |  |     return result; | 
					
						
							|  |  |  |     // return [1,2,3,4,5].map(id => {
 | 
					
						
							|  |  |  |     //   return {id:id, text: 'same as it ever was ...'};
 | 
					
						
							|  |  |  |     // });
 | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  |   // #enddocregion same-as-it-ever-was
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-05-31 18:36:22 -07:00
										 |  |  |   setUpperCaseFirstName(firstName: string) { | 
					
						
							|  |  |  |     // console.log(firstName);
 | 
					
						
							| 
									
										
										
										
											2015-12-07 13:31:26 -08:00
										 |  |  |     this.currentHero.firstName = firstName.toUpperCase(); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   // #docregion setClasses
 | 
					
						
							|  |  |  |   setClasses() { | 
					
						
							| 
									
										
										
										
											2016-01-10 17:07:19 -08:00
										 |  |  |     let classes =  { | 
					
						
							| 
									
										
										
										
											2015-12-07 13:31:26 -08:00
										 |  |  |       saveable: this.canSave,      // true
 | 
					
						
							|  |  |  |       modified: !this.isUnchanged, // false
 | 
					
						
							|  |  |  |       special: this.isSpecial,     // true
 | 
					
						
							| 
									
										
										
										
											2016-05-31 18:36:22 -07:00
										 |  |  |     }; | 
					
						
							| 
									
										
										
										
											2016-01-10 17:07:19 -08:00
										 |  |  |     // #enddocregion setClasses
 | 
					
						
							|  |  |  |     // compensate for DevMode (sigh)
 | 
					
						
							| 
									
										
										
										
											2016-05-31 18:36:22 -07:00
										 |  |  |     if (JSON.stringify(classes) === JSON.stringify(this.priorClasses)) { | 
					
						
							| 
									
										
										
										
											2016-05-03 14:06:32 +02:00
										 |  |  |        return this.priorClasses; | 
					
						
							| 
									
										
										
										
											2016-01-10 17:07:19 -08:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2016-05-03 14:06:32 +02:00
										 |  |  |     this.priorClasses = classes; | 
					
						
							| 
									
										
										
										
											2016-01-10 17:07:19 -08:00
										 |  |  |     // #docregion setClasses
 | 
					
						
							|  |  |  |     return classes; | 
					
						
							| 
									
										
										
										
											2015-12-07 13:31:26 -08:00
										 |  |  |   } | 
					
						
							|  |  |  |   // #enddocregion setClasses
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-01-10 17:07:19 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-12-07 13:31:26 -08:00
										 |  |  |   // #docregion setStyles
 | 
					
						
							|  |  |  |   setStyles() { | 
					
						
							| 
									
										
										
										
											2016-01-10 17:07:19 -08:00
										 |  |  |     let styles = { | 
					
						
							| 
									
										
										
										
											2015-12-13 22:29:37 -08:00
										 |  |  |       // CSS property names
 | 
					
						
							| 
									
										
										
										
											2015-12-07 13:31:26 -08:00
										 |  |  |       'font-style':  this.canSave      ? 'italic' : 'normal',  // italic
 | 
					
						
							|  |  |  |       'font-weight': !this.isUnchanged ? 'bold'   : 'normal',  // normal
 | 
					
						
							| 
									
										
										
										
											2016-01-28 16:01:39 -08:00
										 |  |  |       'font-size':   this.isSpecial    ? '24px'   : '8px',     // 24px
 | 
					
						
							| 
									
										
										
										
											2016-05-31 18:36:22 -07:00
										 |  |  |     }; | 
					
						
							| 
									
										
										
										
											2016-01-10 17:07:19 -08:00
										 |  |  |     // #enddocregion setStyles
 | 
					
						
							|  |  |  |     // compensate for DevMode (sigh)
 | 
					
						
							| 
									
										
										
										
											2016-05-31 18:36:22 -07:00
										 |  |  |     if (JSON.stringify(styles) === JSON.stringify(this._priorStyles)) { | 
					
						
							| 
									
										
										
										
											2016-01-10 17:07:19 -08:00
										 |  |  |        return this._priorStyles; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     this._priorStyles = styles; | 
					
						
							|  |  |  |     // #docregion setStyles
 | 
					
						
							|  |  |  |     return styles; | 
					
						
							| 
									
										
										
										
											2015-12-07 13:31:26 -08:00
										 |  |  |   } | 
					
						
							|  |  |  |   // #enddocregion setStyles
 | 
					
						
							| 
									
										
										
										
											2016-01-10 17:07:19 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-12-13 22:29:37 -08:00
										 |  |  |   toeChoice = ''; | 
					
						
							| 
									
										
										
										
											2016-05-31 18:36:22 -07:00
										 |  |  |   toeChooser(picker: HTMLFieldSetElement) { | 
					
						
							| 
									
										
										
										
											2015-12-07 13:31:26 -08:00
										 |  |  |     let choices = picker.children; | 
					
						
							| 
									
										
										
										
											2016-05-31 18:36:22 -07:00
										 |  |  |     for (let i = 0; i < choices.length; i++) { | 
					
						
							|  |  |  |       let choice = <HTMLInputElement>choices[i]; | 
					
						
							|  |  |  |       if (choice.checked) {return this.toeChoice = choice.value; } | 
					
						
							| 
									
										
										
										
											2015-12-07 13:31:26 -08:00
										 |  |  |     } | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-02-06 17:18:26 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  |   // #docregion trackByHeroes
 | 
					
						
							|  |  |  |   trackByHeroes(index: number, hero: Hero) { return hero.id; } | 
					
						
							|  |  |  |   // #enddocregion trackByHeroes
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   // #docregion trackById
 | 
					
						
							|  |  |  |   trackById(index: number, item: any): string { return item['id']; } | 
					
						
							|  |  |  |   // #enddocregion trackById
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-05-31 18:36:22 -07:00
										 |  |  |   val = 2; | 
					
						
							|  |  |  |   // villainImageUrl = 'http://www.clker.com/cliparts/u/s/y/L/x/9/villain-man-hi.png'
 | 
					
						
							| 
									
										
										
										
											2015-12-07 13:31:26 -08:00
										 |  |  |   // Public Domain terms of use http://www.clker.com/disclaimer.html
 | 
					
						
							| 
									
										
										
										
											2016-05-31 18:36:22 -07:00
										 |  |  |   villainImageUrl = 'images/villain.png'; | 
					
						
							| 
									
										
										
										
											2015-12-07 13:31:26 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-02-06 17:18:26 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  |   //////// Detect effects of NgForTrackBy ///////////////
 | 
					
						
							| 
									
										
										
										
											2016-05-31 18:36:22 -07:00
										 |  |  |   @ViewChildren('noTrackBy') childrenNoTrackBy: QueryList<ElementRef>; | 
					
						
							|  |  |  |   @ViewChildren('withTrackBy') childrenWithTrackBy: QueryList<ElementRef>; | 
					
						
							| 
									
										
										
										
											2016-02-06 17:18:26 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-05-31 18:36:22 -07:00
										 |  |  |   private _oldNoTrackBy: HTMLElement[]; | 
					
						
							|  |  |  |   private _oldWithTrackBy: HTMLElement[]; | 
					
						
							| 
									
										
										
										
											2016-02-06 17:18:26 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  |   heroesNoTrackByChangeCount = 0; | 
					
						
							|  |  |  |   heroesWithTrackByChangeCount = 0; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-05-03 14:06:32 +02:00
										 |  |  |   private detectNgForTrackByEffects() { | 
					
						
							| 
									
										
										
										
											2016-02-06 17:18:26 -08:00
										 |  |  |     this._oldNoTrackBy   = toArray(this.childrenNoTrackBy); | 
					
						
							|  |  |  |     this._oldWithTrackBy = toArray(this.childrenWithTrackBy); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-05-31 18:36:22 -07:00
										 |  |  |     this.childrenNoTrackBy.changes.subscribe((changes: any) => { | 
					
						
							| 
									
										
										
										
											2016-02-06 17:18:26 -08:00
										 |  |  |       let newNoTrackBy = toArray(changes); | 
					
						
							| 
									
										
										
										
											2016-05-31 18:36:22 -07:00
										 |  |  |       let isSame = this._oldNoTrackBy.every((v: any, i: number) => v === newNoTrackBy[i]); | 
					
						
							| 
									
										
										
										
											2016-02-06 17:18:26 -08:00
										 |  |  |       if (!isSame) { | 
					
						
							|  |  |  |         this._oldNoTrackBy = newNoTrackBy; | 
					
						
							|  |  |  |         this.heroesNoTrackByChangeCount++; | 
					
						
							|  |  |  |       } | 
					
						
							| 
									
										
										
										
											2016-05-31 18:36:22 -07:00
										 |  |  |     }); | 
					
						
							| 
									
										
										
										
											2016-02-06 17:18:26 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-05-31 18:36:22 -07:00
										 |  |  |     this.childrenWithTrackBy.changes.subscribe((changes: any) => { | 
					
						
							| 
									
										
										
										
											2016-02-06 17:18:26 -08:00
										 |  |  |       let newWithTrackBy = toArray(changes); | 
					
						
							| 
									
										
										
										
											2016-05-31 18:36:22 -07:00
										 |  |  |       let isSame = this._oldWithTrackBy.every((v: any, i: number) => v === newWithTrackBy[i]); | 
					
						
							| 
									
										
										
										
											2016-02-06 17:18:26 -08:00
										 |  |  |       if (!isSame) { | 
					
						
							|  |  |  |         this._oldWithTrackBy = newWithTrackBy; | 
					
						
							|  |  |  |         this.heroesWithTrackByChangeCount++; | 
					
						
							|  |  |  |       } | 
					
						
							| 
									
										
										
										
											2016-05-31 18:36:22 -07:00
										 |  |  |     }); | 
					
						
							| 
									
										
										
										
											2016-02-06 17:18:26 -08:00
										 |  |  |   } | 
					
						
							|  |  |  |   ///////////////////
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-12-07 13:31:26 -08:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2016-02-06 17:18:26 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  | // helper to convert viewChildren to an array of HTMLElements
 | 
					
						
							| 
									
										
										
										
											2016-05-31 18:36:22 -07:00
										 |  |  | function toArray(viewChildren: QueryList<ElementRef>) { | 
					
						
							| 
									
										
										
										
											2016-02-06 17:18:26 -08:00
										 |  |  |   let result: HTMLElement[] = []; | 
					
						
							|  |  |  |   let children = viewChildren.toArray()[0].nativeElement.children; | 
					
						
							| 
									
										
										
										
											2016-05-31 18:36:22 -07:00
										 |  |  |   for (let i = 0; i < children.length; i++) { result.push(children[i]); } | 
					
						
							| 
									
										
										
										
											2016-02-06 17:18:26 -08:00
										 |  |  |   return result; | 
					
						
							| 
									
										
										
										
											2016-05-03 14:06:32 +02:00
										 |  |  | } |