我有一个带有Blob字段的类,称为徽标,当我想显示此字段时,我不确定如何在Angular中做到这一点,并且知道该应用程序是小型应用程序,如果Blob是存储图像的最佳类型,用户很少。
Company.java
@Entity
public class Company implements Serializable{
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
@Column(name = "id", updatable = false, nullable = false)
private Long id;
@Column(name = "name", unique = true, nullable = false)
private String name;
@Column(name = "activity", nullable = false)
private String activity;
@Column(name = "address", nullable = false)
private String address;
@Column(name = "city", nullable = false)
private String city;
@Column(name = "logo", nullable = true)
private Blob logo;
}
model.company.ts
export class Company{
public id:any;
public name:string;
public activity:string;
public address:string;
public city:string;
public logo:Blob;
}
当我这样做时,它甚至不显示任何其他字符串字段。
<tr *ngFor="let c of pageCompanies?.content">
<td class="py-1"><img src="{{c.logo}}" class="rounded-circle" width="45" height="45"></td>
</tr>
答案 0 :(得分:0)
您是否已将徽标另存为base64?
如果不尝试以下操作:
<tr *ngFor="let c of pageCompanies?.content">
<td class="py-1"><img src="data:image/png;base64,{{c.logo}}" class="rounded-circle" width="45" height="45"></td>
</tr>