This is the method in app.component.ts:
deleteItem(collectionName:string, documentId:string){
this.firestore.collection(collectionName).doc(documentId).delete();
}
Trying to use it in app.component.html:
<button type="button" (click)="deleteItem(item.docId : item.colname)">delete</button>
I am receiving the following error message:
Expected 2 arguments, but got 1.
CodePudding user response:
If you are passing two or more arguments - a) they need to be in the right order (ie: passed in the order that the function expects them to be passed in - which in this case is collection name first and then document id) ) and b) they are separated by a comma not a colon.
deleteItem(collectionName:string, documentId:string){
this.firestore.collection(collectionName).doc(documentId).delete();
}
<button type="button" (click)="deleteItem(item.colname, item.docId)">delete</button>