我一直在創建一個Angular2應用程序,我想更新Firebase中用戶的配置文件,我正在使用AngularFire2。 例如,當我試圖更新誰擁有關鍵的「nmH5ZmawpQgogoCRVFVfNaBN6xg1」,當我點擊鏈接來更新它的錯誤的用戶配置文件出現 EXCEPTION: Error in ./ProfilComponent class ProfilComponent - inline template:82:10 caused by: Firebase.update failed: First argument contains a function in property 'users.nmH5ZmawpQgogoCRVFVfNaBN6xg1.$exists' with contents: function() { return snapshot.exists(); }
AngularFire2 Firebase.update failed snapshot.exists()
user.service.ts
users:FirebaseListObservable<any>;
updateUser(user:IUser){
this.users=this.af.database.list('/users');
this.users.update(user.uid,user);
}
用戶.ts
export interface IUser {
avatarUrl:string;
createdDate:string;
birthDate:string;
displayName:string;
email:string;
gendre:string;
interests:Interest[];
job:Job[];
location:ILocation;
plateform:string;
uid:string;
}
在此先感謝。
解決方法是從用戶對象中刪除$ key屬性和$ exists函數:delete this.user ['$ key'];刪除this.user ['$ exists']; – naruto