Html img src未在ngFor循环内显示
我有一些代码打算显示默认的用户配置文件图像或用户刚刚上传的配置文件图像,但是默认图像不会显示在div中,只有在用户上传自己的配置文件图像后,才会显示他们的图像 我可以在网格外看到默认图像本身Html img src未在ngFor循环内显示,html,typescript,ionic4,Html,Typescript,Ionic4,我有一些代码打算显示默认的用户配置文件图像或用户刚刚上传的配置文件图像,但是默认图像不会显示在div中,只有在用户上传自己的配置文件图像后,才会显示他们的图像 我可以在网格外看到默认图像本身 <ion-content> <ion-grid style ="text-align: center"> <ion-row > <ion-col *ngFor="let item of students" > <div class=
<ion-content>
<ion-grid style ="text-align: center">
<ion-row >
<ion-col *ngFor="let item of students" >
<div class= "imageHold" >
<img [src]= "profileImage">
</div>
</ion-col>
</ion-row >
<ion-row style ="text-align: center">
<ion-col>
<ion-button size="small" fill="outline" (click)="chooseProfilePic()" >Choose Profile Photo</ion-button>
</ion-col>
</ion-row>
</ion-grid>
ts中的firebase代码段
this.firebaseService.uploadImage(image_src, randomId)
.then(photoURL => {
this.profileImage = photoURL;
loading.dismiss();
toast.present();
}, err =>{
console.log(err);
})
}
profileImage不应该是字符串而不是数组吗? 像这样:
this.profileImage=“/assets/imgs/user.png”代码>
此外,根据爱奥尼亚文件,您应该使用:
它不是在查看这个.students.profileImage
吗?您将默认值存储在这个.profileImage
中?使用ionImg来实现此目的。请参阅此链接
this.firebaseService.uploadImage(image_src, randomId)
.then(photoURL => {
this.profileImage = photoURL;
loading.dismiss();
toast.present();
}, err =>{
console.log(err);
})
}