Начало Superclass выглядит так:
TimeEditorComponent), multi: true },
{ provide: NG_VALIDATORS, useExisting: forwardRef(() => TimeEditorComponent), multi: true }]
})
export class TimeEditorComponent extends DigitSequenceEditorDirective implements OnInit {
// ...
[/code]
Проблема сейчас, переносив это в Angular 19 и пытается использовать автономный дизайн, заключается в том, что HTML для директивы содержит некоторые функции CommonModule, такие как [ngclass] и [ngstyle] . (Существует также использование *ngif и т.п., но я могу избавиться от использования @if , @for и т. Д.) PrettyPrint-Override ">
Код: Выделить всё
import { Directive, Input } from '@angular/core';
import { NgIf } from '@angular/common';
@Directive({
selector: '[appMyStandalone]',
standalone: true,
imports: [NgIf] // Can't be done! No `imports` field! (I'd have NgClass and NgStyle here if this worked)
})
export class MyStandaloneDirective {
@Input() appMyStandalone: boolean = false;
}
Подробнее здесь: https://stackoverflow.com/questions/794 ... -directive
Мобильная версия