I need help on how to add sanitization to the url and alt text of this code. What is the best way to do this as this is something I'm not very familiar with. I tried researching but not able to find a clear answer. I added DomSanitizer to typescript for the src but not sure if this is correct and I don't know what to use for alt
angular/html
<sdps-card-image src={{cardData.image?.url}} alt={{cardData.image?.altText}} is-
responsive="true">
</sdps-card>
ts
import { Component,Input } from '@angular/core';
import { Card } from "../../models/card.model";
import { DomSanitizer } from '@angular/platform-browser';
@Component({
selector: 'app-card',
templateUrl: './card.component.html',
})
export class CardComponent {
@Input() cardData = new Card();
constructor(private sanitizer: DomSanitizer) {}
transform(value: string) {
return (this.sanitizer.bypassSecurityTrustResourceUrl(value));
}
}
Any assistance would be appreciated on how to get the correct code to fix this would be appreciated.