Angular Froala-将图像上载到firebase
我已经将Froala集成到我的Angular项目中,我正试图让它将图像上传到我的firebase存储中 我目前正试图让它在Angular Froala-将图像上载到firebase,angular,firebase-storage,froala,Angular,Firebase Storage,Froala,我已经将Froala集成到我的Angular项目中,我正试图让它将图像上传到我的firebase存储中 我目前正试图让它在图像中这样做。在上传之前 我在github中发现了一些代码,它们让我朝着正确的方向前进: 有没有人能在我还留着头发的时候给我指引正确的方向 当我运行以下命令时,我得到无法读取未定义的属性“storage” 我知道这与constfileref行有关,但我不确定如何修复它 原作者指出:我不得不使用技巧self=this,因为函数中的this引用了编辑器 您好,我没有您的代码的全
图像中这样做。在上传之前
我在github中发现了一些代码,它们让我朝着正确的方向前进:
有没有人能在我还留着头发的时候给我指引正确的方向
当我运行以下命令时,我得到无法读取未定义的属性“storage”
我知道这与constfileref
行有关,但我不确定如何修复它
原作者指出:我不得不使用技巧self=this
,因为函数中的this引用了编辑器
您好,我没有您的代码的全部范围,但有问题的错误是在“this”上找不到“storage”,这通常是对方法或变量的本地引用。您是否在“存储”方法中定义了Firebase.storage,或将其定义为某种导入?
self = this;
public options1: Object = {
imageMaxSize: 2 * 1024 * 1024,
imageAllowedTypes: ['jpeg', 'jpg', 'png'],
events: {
'image.beforeUpload': function (images) {
const fileRef = this.storage.ref('/images/');
const task: AngularFireUploadTask = fileRef.put(images[0]);
task.snapshotChanges().pipe(
finalize(() => {
fileRef.getDownloadURL().subscribe((downloadURL) => {
this.image.insert(downloadURL, null, null, this.image.get());
});
})
)
.subscribe();
},
},
placeholderText: "Start typing..."
};