我一直在创建一个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