refactor: migra decoradores a signals (input/output/viewChild/contentChild)
This commit is contained in:
@@ -1,21 +1,22 @@
|
||||
import { Directive, ElementRef, HostBinding, Input, OnInit, Renderer2 } from '@angular/core';
|
||||
import { Directive, ElementRef, HostBinding, OnInit, Renderer2, input } from '@angular/core';
|
||||
import { unit } from '../models';
|
||||
|
||||
@Directive()
|
||||
export abstract class PiBaseAffixDirective implements OnInit {
|
||||
@HostBinding('class') get classes(): string {
|
||||
return ['pi-affix', `pi-affix__appearance--${this.appearance}`].join(' ');
|
||||
return ['pi-affix', `pi-affix__appearance--${this.appearance()}`].join(' ');
|
||||
}
|
||||
|
||||
@Input() unit: unit | string | undefined;
|
||||
@Input() appearance: 'ghost' | 'fill' = 'ghost';
|
||||
readonly unit = input<unit | string>();
|
||||
readonly appearance = input<'ghost' | 'fill'>('ghost');
|
||||
|
||||
constructor(private renderer: Renderer2, private el: ElementRef) {}
|
||||
|
||||
ngOnInit() {
|
||||
if (this.unit) {
|
||||
const unitValue = this.unit();
|
||||
if (unitValue) {
|
||||
const span = this.renderer.createElement('span');
|
||||
const text = this.renderer.createText(this.unit);
|
||||
const text = this.renderer.createText(unitValue);
|
||||
|
||||
this.renderer.appendChild(span, text);
|
||||
this.renderer.appendChild(this.el.nativeElement, span);
|
||||
|
||||
Reference in New Issue
Block a user