Angular 6 Iframe Binding August 07, 2024 Post a Comment There is a variable that stores iframe code. I want to bind this in a div, but nothing work. html: ts: yt = 'Solution 1: You probably might get a warning saying that it's unsafe HTML. That's why Angular is not rendering it inside the div.You'll have to DomSanitize it: <divclass="top-image" [innerHTML]="yt | safe: 'html'"></div>CopyHere's the pipe courtesy Swarna Kishore.Baca JugaGoogle Chrome Warning: Password Forms Should Have (optionally Hidden) Username Fields For AccessibilityMat Paginator Items Per Page Not Working In Angular 9Select All Or Highlight All Text In An Elementimport { Pipe, PipeTransform } from'@angular/core'; import { DomSanitizer, SafeHtml, SafeStyle, SafeScript, SafeUrl, SafeResourceUrl } from'@angular/platform-browser'; @Pipe({ name: 'safe' }) exportclassSafePipeimplementsPipeTransform { constructor(protected sanitizer: DomSanitizer) {} publictransform(value: any, type: string): SafeHtml | SafeStyle | SafeScript | SafeUrl | SafeResourceUrl { switch (type) { case'html': returnthis.sanitizer.bypassSecurityTrustHtml(value); case'style': returnthis.sanitizer.bypassSecurityTrustStyle(value); case'script': returnthis.sanitizer.bypassSecurityTrustScript(value); case'url': returnthis.sanitizer.bypassSecurityTrustUrl(value); case'resourceUrl': returnthis.sanitizer.bypassSecurityTrustResourceUrl(value); default: thrownewError(`Invalid safe type specified: ${type}`); } } } CopyHere's a Sample StackBlitz. Share You may like these postsPutting My Java Slick Game Onto A WebsiteUpload A File That Lives On The Website Server To Another Service Via AjaxUncaught Notfounderror: Failed To Execute 'appendchild' On 'node': The New Child Element Is NullSave Image On My Computer As Html To Embed In Email? Post a Comment for "Angular 6 Iframe Binding"
Post a Comment for "Angular 6 Iframe Binding"