title: How to get from outside value inside subscriber
body: <p>I'm developing dashboard with chartjs and Angular 7 and I need to display some information from an object inside tooltip.</p>
  
  <p><a href="https://i.stack.imgur.com/8cUOX.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/8cUOX.png" alt="enter image description here"></a></p>
  
  <p>I'm able to get the object in console log, but I'don't know how to get the value from a subscriber inside function that permits me to display custom tooltip on screen.</p>
  
  <p>this is my code.</p>
  
  <pre><code>ngOnInit() {
  
  this.batches.forEach(batch =&gt; {
          let batchID = batch.batch_id;
          this.dashboardService.getBatchId(batchID).subscribe(singleBatch =&gt; {
            this.batch = singleBatch;
            console.log(this.batch)
            let batchName = this.batch.name //&lt;-- THIS IS MY VARIABLE
            console.log(batchName)
          })
        })
  }
  
  Duration = {
      tooltips: {
        // Disable the on-canvas tooltip
        enabled: false,
  
        custom: function(tooltipModel) {
            // Tooltip Element
            var tooltipEl = document.getElementById('chartjs-tooltip');
  
            // Create element on first render
            if (!tooltipEl) {
                tooltipEl = document.createElement('div');
                tooltipEl.id = 'chartjs-tooltip';
                tooltipEl.innerHTML = '&lt;table style="background-color: #eee;"&gt;&lt;/table&gt;';
                document.body.appendChild(tooltipEl);
            }
  
            function getBody(bodyItem) {
                return bodyItem.lines;
            }
  
            // Set Text
            if (tooltipModel.body) {
                var titleLines = tooltipModel.title || [];
                var bodyLines = tooltipModel.body.map(getBody);
                innerHtml += '&lt;tbody&gt;';
  
                bodyLines.forEach(function(body, i) {
                    var span = '&lt;span&gt;' +
                    '&lt;p&gt;Batch: &lt;/p&gt;' + //&lt;----HERE IT IS THE PLACE WHERE I WANT TO PUT BATCHNAME
                    '&lt;/span&gt;';
                    innerHtml += '&lt;tr&gt;&lt;td&gt;' + span + body + '&lt;/td&gt;&lt;/tr&gt;';
                });
                innerHtml += '&lt;/tbody&gt;';
            }
        }
  
    }
  };
  
  </code></pre>
  
  <p>thanks in advance.</p>