Angular 中的消毒
Sanitization in Angular
我有一个具有 photoPath 属性的子模型
export interface Child {
chIld: number;
firstName: string;
photoPath?: string;
photos: Photo[];
}
我正在尝试清理 photoPath 以绕过 angular 安全性
export class ChildrenCardComponent implements OnInit {
@Input() children: Child;
public imgurl: Child["photoPath"];
constructor(private sanitizer: DomSanitizer) {
this.sanitizer.bypassSecurityTrustResourceUrl(this.imgurl)
}
ngOnInit(): void {
}
}
路径在数组中被调用和分配(public imgurl: Child["photoPath"];
)
HMTL 调用 imgurl 如下所示:
<img [src]="imgurl >
已解决
@Input() children: Child;
public imgurl: any;
constructor(public sanitizer: DomSanitizer) {
}
ngOnInit(): void {
this.imgurl=this.sanitizer.bypassSecurityTrustResourceUrl(this.children.photoPath)
}
我有一个具有 photoPath 属性的子模型
export interface Child {
chIld: number;
firstName: string;
photoPath?: string;
photos: Photo[];
}
我正在尝试清理 photoPath 以绕过 angular 安全性
export class ChildrenCardComponent implements OnInit {
@Input() children: Child;
public imgurl: Child["photoPath"];
constructor(private sanitizer: DomSanitizer) {
this.sanitizer.bypassSecurityTrustResourceUrl(this.imgurl)
}
ngOnInit(): void {
}
}
路径在数组中被调用和分配(public imgurl: Child["photoPath"];
)
HMTL 调用 imgurl 如下所示:
<img [src]="imgurl >
已解决
@Input() children: Child;
public imgurl: any;
constructor(public sanitizer: DomSanitizer) {
}
ngOnInit(): void {
this.imgurl=this.sanitizer.bypassSecurityTrustResourceUrl(this.children.photoPath)
}