libs/time/src/lib/timespan-button/timespan-button.component.ts
selector | n52-timespan-button |
templateUrl | ./timespan-button.component.html |
Methods |
|
Inputs |
Outputs |
constructor(predefinedSrvc: DefinedTimespanService)
|
||||||
Parameters :
|
label | |
Type : string
|
|
predefined | |
Type : string | DefinedTimespan
|
|
timespanFunc | |
Type : function
|
|
onTimespanSelected | |
Type : EventEmitter<Timespan>
|
|
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>