File

libs/time/src/lib/timespan-button/timespan-button.component.ts

Metadata

selector n52-timespan-button
templateUrl ./timespan-button.component.html

Index

Methods
Inputs
Outputs

Constructor

constructor(predefinedSrvc: DefinedTimespanService)
Parameters :
Name Type Optional
predefinedSrvc DefinedTimespanService No

Inputs

label
Type : string
predefined
Type : string | DefinedTimespan
timespanFunc
Type : function

Outputs

onTimespanSelected
Type : EventEmitter<Timespan>

Methods

Public clicked
clicked()
Returns : void
import { Component, EventEmitter, Input, Output } from '@angular/core';
import { DefinedTimespan, DefinedTimespanService, Timespan } from '@helgoland/core';

@Component({
  selector: 'n52-timespan-button',
  templateUrl: './timespan-button.component.html'
})
export class TimespanButtonComponent {

  @Input()
  public predefined: string | DefinedTimespan;

  @Input()
  public label: string;

  @Input()
  public timespanFunc: () => Timespan;

  @Output()
  public onTimespanSelected: EventEmitter<Timespan> = new EventEmitter();

  constructor(
    protected predefinedSrvc: DefinedTimespanService
  ) { }

  public clicked() {
    if (this.predefined) {
      this.onTimespanSelected.emit(this.predefinedSrvc.getInterval(this.predefined as DefinedTimespan));
      return;
    }
    if (this.timespanFunc) {
      this.onTimespanSelected.emit(this.timespanFunc());
      return;
    }
    this.onTimespanSelected.emit();
  }

}
<button type="button" class="btn" (click)="clicked()">
  {{label}}
</button>
Legend
Html element
Component
Html element with directive

result-matching ""

    No results matching ""