Angular will implement sanitization by default to avoid unnecessary content loading into an angular app for security reason
Example: Video content,pdf content,.. Angular is providing DOMSanitizer class to skip the sanitization for trusted resources[like video,pdf,..] Please refer Previous Example
https://dotnetbyudayrajakonda.blogspot.com/2023/10/property-binding-in-angular.html
demo-Component.ts
import { Component } from '@angular/core';import { DomSanitizer } from '@angular/platform-browser';@Component({selector: 'app-demo',templateUrl: './demo.component.html',styleUrls: ['./demo.component.css']})export class DemoComponent {prodid:string="p001";prodname:string="aiwa";prodprice:number=50000;samplepic:string="assets/aiwa.jpg";invalid:boolean=false;msg:string="<h2>registered..</h2>";unsafeurl:string="../assets/sample.mp4";safeurl:any;constructor(private _domsanitizer:DomSanitizer) {this.safeurl=this._domsanitizer.bypassSecurityTrustResourceUrl(this.unsafeurl);}}
.html
Note: ----- Domsanitizer class bypassSecurityTrustResourceUrl method will inform angular,the resource is trusted by developer, so load the resource into an angular app If you provide unsafeurl variable to iframe src property ,it will not play a video,goto inspect console,it will show security error message.
Output
No comments:
Post a Comment
Thank you for visiting my blog