view 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 source
/**
 * 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);
      }
    });
  }
}