import { Component , ElementRef } from '@angular/core' ; import { MapService } from './map.service' ; @ Component ( { selector : 'esri-legend' , template : '<div></div>' } ) export class LegendComponent { constructor ( private elRef , private _mapService ) { } legend : any ; init ( map , layerInfos ) { this . legend = this . _mapService . createLegend ( { map , layerInfos } , this . elRef . nativeElement . firstChild ) ; this . legend . startup ( ) ; } ngOnDestroy ( ) { if ( this . legend ) { this . legend . destroy ( ) ; } } }