-
Notifications
You must be signed in to change notification settings - Fork 244
Open
Labels
package: eslint-pluginAngular-specific TypeScript rulesAngular-specific TypeScript rulestriageThis issue needs to be looked at and categorized by a maintainerThis issue needs to be looked at and categorized by a maintainer
Description
//...
@Directive({
standalone: true,
selector: 'img[loading="lazy"],img[tuiLoading="lazy"]',
providers: [TuiLazyLoadingService, IntersectionObserverService],
host: {
'[style.animation]': 'animation()',
'[style.background]': 'background()',
'[attr.loading]': 'supported ? "lazy" : null',
'[attr.src]': 'src()',
'(load)': 'unset()',
'(error)': 'unset()',
},
})
export class TuiImgLazyLoading {
private readonly isServer = isPlatformServer(inject(PLATFORM_ID));
private readonly loading$ = inject(TuiLazyLoadingService);
protected readonly supported = 'loading' in tuiInjectElement<HTMLImageElement>();
protected src = signal<SafeResourceUrl | string | null>(null);
protected background = signal(this.isServer ? '' : 'var(--tui-background-neutral-2)');
protected animation = signal(
this.isServer ? '' : 'tuiSkeletonVibe ease-in-out 1s infinite alternate',
);
protected readonly $ =
!this.supported &&
this.loading$.pipe(takeUntilDestroyed()).subscribe((src) => this.src.set(src)); // ✖ 1 problem (1 error, 0 warnings)
@Input('src')
public set srcSetter(src: SafeResourceUrl | string) {
if (this.supported) {
this.src.set(src);
} else {
this.loading$.next(src);
}
}
protected unset(): void {
this.background.set('');
this.animation.set('');
}
}

Why I have an error?
Metadata
Metadata
Assignees
Labels
package: eslint-pluginAngular-specific TypeScript rulesAngular-specific TypeScript rulestriageThis issue needs to be looked at and categorized by a maintainerThis issue needs to be looked at and categorized by a maintainer