<!--HTML CODE--> <p #mass_timings></p>
//Controller code @ViewChild('mass_timings') mass_timings: ElementRef; constructor(private domSanitizer:DomSanitizer) getInnerHTMLValue(){ this.mass_timings.nativeElement.innerHTML = this.domSanitizer.bypassSecurityTrustHtml(this.parishDetail.mass_timings); }
but the output which the mass_timings is displaying is including the text:-
Safe value must use [property]=binding
at the beginning
How to remove this string.
As the error message says, the sanitized HTML needs to be added using property binding:
<p [innerHTML]="massTimingsHtml"></p>
constructor(private domSanitizer:DomSanitizer) { this.massTimingsHtml = this.getInnerHTMLValue(); } getInnerHTMLValue(){ return this.domSanitizer.bypassSecurityTrustHtml(this.parishDetail.mass_timings); }
StackBlitz example (based on Swapnil Patwa's Plunker - see comments below)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With