Hello everyone, I'm trying to optimize an angular website. My first task is image optimization. I read the documentation and guide for NgOptimizedImage here:
https://angular.io/guide/image-directive
Sorry if I misunderstood, but this is my understanding. I do not a loader (step 2) and I'm trying to load an image from my assets folder. So I've imported NgOptimizedImage from @angular/common and added it to imports in the base app.module.ts. On my component the image is loaded with
<img ngSrc="../../../assets/img/calidad-catracha.webp" height="427" width="640"
fill priority
alt="Calidad Catracha Background Image"
>
This code does not load the image, it just renders the alt value as if the file missing, I also get no errors from console.
If i try to bind to the value, where imageSource = "../../../assets/img/calidad-catracha.webp"
<img [ngSrc]="imageSource" height="427" width="640"
fill priority
alt="Calidad Catracha Background Image"
>
I get error "Can't bind to 'ngSrc' since it isn't a known property of 'img'"
If I just use src instead of ngSrc the image is loaded correctly.
I've also tried googling it without finding a mention of this error. I also asked chatGPT and it's not being any help either.
I'm the attaching the output of ng version and I'm marking it as beginner as I can't find other tag related to it. Excuse any mistakes, it's my first time working with optimization.