I have a component "CompA" which has a function named getDocID(), that takes a value from the template on a mouse click and then gets an object asynchronously after doing some query in the firebase with that value.
The problem is, I need to pass this object to another component "CompB" on routing.
This is how my code is looking like right now:
Template:
 <a (click)="getDocID(doc.docID)">Edit this Document</a>
Component:
getDocID(docID){
  this._docEditService.getSingleDoc(docID, singleDoc => {
    //here will come the async singleDoc object which I need to pass to the edit-doc route
  });
  this._router.navigate(['edit-doc']);
}
Service:
    getSingleDoc(docID, callback) {
    this.userSingleDoc = this.af.database.list('docs', {
      query: {
        orderByChild: 'docID',
        equalTo: docID
      }
    });
    this.userSingleDoc.forEach(element => {
      for (var el in element) {
        var x = element[el];
        var singleDoc = {
          docID: x['$key'],
          docTitle: x.docTitle,
          docDescription: x.docDescription,
          timestamp: x.timestamp,
        }
        callback(singleDoc)
      }
    });
  }
