Hi I´m triyin to build a function to be reusable, and sanitize some content, but I don´t know hoe to call DomSanitizer
it allways give me the error that is and abstract class.
Here is my function:
export function PostFormat(post){
let sanitizer: DomSanitizer; // TODO!
post['title'] = sanitizer.bypassSecurityTrustHtml(post['title']['rendered']);
post['author'] = post['_embedded']['author'][0];
post['content'] = sanitizer.bypassSecurityTrustHtml(post['content']['rendered']);
post['excerpt'] = sanitizer.bypassSecurityTrustHtml(post['excerpt']['rendered']);
if (post['_embedded']['wp:featuredmedia']){
if (post['_embedded']['wp:featuredmedia'][0]['media_details']){
post['featured_image'] = post['_embedded']['wp:featuredmedia'][0]['media_details']['sizes'][this.default_size]['source_url'];
}
}
if (post['_embedded']['replies']){
post['comments'] = post['_embedded']['replies'][0];
}
return post;
}
Easy way to use it is add import
after that you can use all funcs of sanitizer
and add your text like
inner html