我有一个具有属性 photoPath 的子模型
export interface Child {
chIld: number;
firstName: string;
photoPath?: string;
photos: Photo[];
}
我正在尝试清理 photoPath 以绕过角度安全性
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 >