Angular 角度firebase不支持的字段值
我有uplaod.ts文件:Angular 角度firebase不支持的字段值,angular,typescript,firebase,firebase-realtime-database,firebase-storage,Angular,Typescript,Firebase,Firebase Realtime Database,Firebase Storage,我有uplaod.ts文件: export class Project { $key: string; file: File; name: string; title: string; //can't write this to db with ngModel (look below) cat: string; //can't write this to db with ngModel (look below) url: string; progress: numb
export class Project {
$key: string;
file: File;
name: string;
title: string; //can't write this to db with ngModel (look below)
cat: string; //can't write this to db with ngModel (look below)
url: string;
progress: number;
createdAt: Date = new Date();
constructor(file: File) {
this.file = file;
}
}
然后在upload.service中,我有一个带有savefiledata()的pushUpload()函数:
upload.html:
<div class="box">
<h3>Single File Upload</h3>
<label>
<input type="file" class="button" (change)="detectFiles($event)">
</label>
<label>
<input [(ngModel)]="proinfo.title" type="text" class="button">
</label>
<label>
<input [(ngModel)]="proinfo.cat" type="text" class="button">
</label>
<button class="button is-primary"
[disabled]="!selectedFiles"
(click)="uploadSingle()">
Upload Single
</button>
<hr>
<h3>Multiple File Upload</h3>
<label>
<input type="file" class="button" (change)="detectFiles($event)" multiple>
</label>
<button class="button is-primary"
[disabled]="!selectedFiles"
(click)="uploadMulti()">
Upload Multiple
</button>
</div>
单文件上传
上传单个
多文件上传
上传多个
我收到0个错误,数据未保存在数据库中(仅名称、url和进度)。
主要问题是:如何将标题和cat保存在数据库中,并将url、名称和进度保存在同一个列表中
selectedFiles: FileList | null;
currentUpload: Project;
proinfo = {} as Project;
uploadSingle() {
const file = this.selectedFiles;
if (file && file.length === 1) {
this.currentUpload = new Project(file.item(0));
this.navSrv.pushUpload(this.currentUpload);
} else {
console.error('No file found!');
}
}
<div class="box">
<h3>Single File Upload</h3>
<label>
<input type="file" class="button" (change)="detectFiles($event)">
</label>
<label>
<input [(ngModel)]="proinfo.title" type="text" class="button">
</label>
<label>
<input [(ngModel)]="proinfo.cat" type="text" class="button">
</label>
<button class="button is-primary"
[disabled]="!selectedFiles"
(click)="uploadSingle()">
Upload Single
</button>
<hr>
<h3>Multiple File Upload</h3>
<label>
<input type="file" class="button" (change)="detectFiles($event)" multiple>
</label>
<button class="button is-primary"
[disabled]="!selectedFiles"
(click)="uploadMulti()">
Upload Multiple
</button>
</div>