AW6241 ng-18 adopt ng-openlayers
This commit is contained in:
25
projects/ng-openlayers/src/lib/attributions.component.ts
Normal file
25
projects/ng-openlayers/src/lib/attributions.component.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import { AfterViewInit, Component, ContentChildren, Host, QueryList } from '@angular/core';
|
||||
import { SourceComponent } from './sources/source.component';
|
||||
import { AttributionComponent } from './attribution.component';
|
||||
|
||||
@Component({
|
||||
selector: 'aol-attributions',
|
||||
template: '<ng-content></ng-content>',
|
||||
})
|
||||
export class AttributionsComponent implements AfterViewInit {
|
||||
@ContentChildren(AttributionComponent)
|
||||
attributions: QueryList<AttributionComponent>;
|
||||
|
||||
instance: Array<string>;
|
||||
|
||||
constructor(@Host() private source: SourceComponent) {}
|
||||
|
||||
/* we can do this at the very end */
|
||||
ngAfterViewInit() {
|
||||
if (this.attributions.length) {
|
||||
this.instance = this.attributions.map((cmp) => cmp.label);
|
||||
// console.log('setting attributions:', this.instance);
|
||||
this.source.instance.setAttributions(this.instance);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user