19 lines
482 B
TypeScript
19 lines
482 B
TypeScript
import { Directive, HostBinding, input } from '@angular/core';
|
|
|
|
@Directive({ selector: '[pi-value]', })
|
|
export class PiValueDirective {
|
|
@HostBinding('class') get classes(): string | boolean {
|
|
return ['pi-value', this.value() > 0 ? 'is-positive' : 'is-negative'].join(' ');
|
|
}
|
|
|
|
readonly value = input.required<number>();
|
|
|
|
checkValue(): string {
|
|
if (this.value() > 0) {
|
|
return 'is-positive';
|
|
} else {
|
|
return 'is-negative';
|
|
}
|
|
}
|
|
}
|