最近我一直在开发应用程序,但在尝试组装所有内容时我发现了一些困难。 我的想法是有一个我可以提交数据+图像的地方,这是我想出的地方。
这是我有firebase发布数据配置的component.ts,以防你想看到它。
import { Component, OnInit } from '@angular/core';
import { AngularFireDatabase, FirebaseListObservable } from 'angularfire2/database';
import { moveIn, moveInLeft, fallIn } from '../router.animations';
interface utilfaq {
erro: string;
solucao: string;
programa:string;
tema:string;
subtema:string;
$key?: string;
}
@Component({
selector: 'app-submissoesv2',
templateUrl: './submissoesv2.component.html',
styleUrls: ['./submissoesv2.component.css'],
animations: [moveIn()],
host: {'[@moveIn]': ''}
})
export class Submissoesv2Component{
readonly errosPath = "erros";
formutilfaq: utilfaq = {
'erro' : '',
'solucao' : '',
'programa' : '',
'tema' : ',',
'subtema' : ',',
};
utilfaqsStream: FirebaseListObservable <utilfaq[]>;
constructor(db:AngularFireDatabase){
this.utilfaqsStream = db.list(this.errosPath);
}
onSubmit(): void{
this.utilfaqsStream.push(this.formutilfaq);
this.formutilfaq = {
'erro' : '',
'solucao' : '',
'programa' : '',
'tema' : '',
'subtema' : ',',
};
try {
if (this.formutilfaq.$key) {
this.utilfaqsStream.update(this.formutilfaq.$key, this.formutilfaq);
} else {
this.utilfaqsStream.push(this.utilfaqsStream);
}
this.formutilfaq = {
'erro': '',
'solucao': '',
'programa' : '',
'tema' :'',
'subtema' : ',',
};
} catch (e) {
console.log('Form error:', e);
}
}
edit(utilfaq: utilfaq): void {
this.formutilfaq = utilfaq;
}
remove(utilfaqKey: string): void {
this.utilfaqsStream.remove(utilfaqKey);
}
}
&#13;
我的问题是我是否可以使用图像将数据发送到firebase。我会在表单上插入一个阵营来上传图片,如果有人可以帮助我,我会很感激。