Firebase 存储和 angularfire2

2023-12-21

如何使用 Angular Fire 2 从 Firebase 存储中获取图像。非常感谢!

constructor(public af: AngularFire) {
this.items = af.database.list('/message');
this.picture = af.database.list('/profile');
}

目前尚未与 AngularFire2 和 Firebase Storage 进行正式集成。不过,使用常规 SDK 非常容易。

@Component({

})
class MyComponent {
  image: string;
  constructor() {
    const storageRef = firebase.storage().ref().child('path/image.png');
    storageRef.getDownloadURL().then(url => this.image = url);
  }
}

然后在你的模板中

<img [src]="image" />
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Firebase 存储和 angularfire2 的相关文章

随机推荐