Skip to content

Commit 7056b02

Browse files
committed
fix: Replace inject() with constructor injection to fix production build
Changed from inject() in field initializers to traditional constructor injection for DomSanitizer. The inject() function in field initializers can cause provider resolution errors in production AOT builds. Removed unused DestroyRef and takeUntilDestroyed imports.
1 parent 30d6e23 commit 7056b02

1 file changed

Lines changed: 4 additions & 8 deletions

File tree

src/lib/components/perfect-select/perfect-select.component.ts

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,11 @@ import {
1212
OnChanges,
1313
SimpleChanges,
1414
ElementRef,
15-
ViewChild,
16-
inject,
17-
DestroyRef
15+
ViewChild
1816
} from '@angular/core';
1917
import { CommonModule } from '@angular/common';
2018
import { FormsModule, ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';
2119
import { DomSanitizer, SafeHtml } from '@angular/platform-browser';
22-
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
2320
import { selectAnimations } from '../../animations/select.animations';
2421
import { ClickOutsideDirective } from '../../directives/click-outside.directive';
2522
import { THEMES, ThemeName } from '../../constants/themes.constant';
@@ -46,8 +43,7 @@ import {
4643
}]
4744
})
4845
export class PerfectSelectComponent implements ControlValueAccessor, OnInit, OnChanges, OnDestroy {
49-
private destroyRef = inject(DestroyRef);
50-
private sanitizer = inject(DomSanitizer);
46+
private sanitizer: DomSanitizer;
5147

5248
// Core Props
5349
@Input() options: SelectOption[] = [];
@@ -280,8 +276,8 @@ export class PerfectSelectComponent implements ControlValueAccessor, OnInit, OnC
280276
private onChange: any = () => {};
281277
private onTouched: any = () => {};
282278

283-
constructor() {
284-
// Constructor intentionally empty - initialization happens in ngOnInit
279+
constructor(sanitizer: DomSanitizer) {
280+
this.sanitizer = sanitizer;
285281
}
286282

287283
ngOnChanges(changes: SimpleChanges): void {

0 commit comments

Comments
 (0)