object()
是一种方法
AngularFireDatabase
类:
object(pathOrRef: PathReference): AngularFireObject {
const ref = getRef(this.database, pathOrRef);
return createObjectReference(ref, this);
}
</code>
https://github.com/angular/angularfire2/blob/master/src/database/database.ts#L37
因为它是类型
AngularFireObject
那么你可以使用以下方法:
method
set(value: T) Replaces the current value in the database with the new value specified as the parameter. This is called a destructive update, because it deletes everything currently in place and saves the new value.
update(value: T) Updates the current value with in the database with the new value specified as the parameter. This is called a non-destructive update, because it only updates the values specified.
remove() Deletes all data present at that location. Same as calling set(null).
</code>
https://github.com/angular/angularfire2/blob/master/docs/rtdb/objects.md#api-summary
因此,没有
push()
方法。
在您的代码中,您似乎只想添加数据,因此您可以使用
push()
在里面
AngularFireList
。例:
const itemsRef = db.list(‘items’);
itemsRef.push({ name: newName });
</code>
阅读文档:
https://github.com/angular/angularfire2/blob/master/docs/rtdb/lists.md