When you construct a custom type and trying to add to firestore.
with the following text book code:
constructor(private afs: AngularFirestore) { this.itemsCollection = afs.collection<Item>('items'); this.items = this.itemsCollection.valueChanges(); }add(item: Item){ this.itemsCollection.add(item); }
There will be an error:
Exception caught: (FirebaseError) : Function CollectionReference.add() requires its first argument to be of type object, but it was: a custom Item object
So need a simple conversion to JSON
add(item: Inventory){ this.itemsCollection.add(JSON.parse(JSON.stringify(item))); }
Khel