Mercurial > hg > ugly-duckling
diff src/app/visualisations/vertical-scale.component.ts @ 388:5f775358c3cf
Introduce vertical-scale component which is a polymorphic container, the child components know how to render their own scales.
author | Lucas Thompson <dev@lucas.im> |
---|---|
date | Thu, 01 Jun 2017 10:02:37 +0100 |
parents | |
children | a02e6ec4a9d2 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/app/visualisations/vertical-scale.component.ts Thu Jun 01 10:02:37 2017 +0100 @@ -0,0 +1,30 @@ +/** + * Created by lucas on 01/06/2017. + */ +import {VerticallyBounded} from "./waves-base.component"; +import { + ChangeDetectionStrategy, + Component, + ContentChildren, + QueryList, + AfterViewInit +} from "@angular/core"; + +@Component({ + selector: 'ugly-vertical-scale', + template: '<ng-content></ng-content>', + changeDetection: ChangeDetectionStrategy.OnPush +}) +export class VerticalScaleComponent implements AfterViewInit { + + @ContentChildren(VerticallyBounded) bounded: QueryList<VerticallyBounded>; + + ngAfterViewInit(): void { + this.bounded.forEach(component => { + const range = component.range; + if (range) { + component.renderScale(range); + } + }); + } +}