title: Angular/SVG - capture element width on page load
body: <p>I have a demo <a href="https://stackblitz.com/edit/ng-tootltip-pj9nt8?file=src%2Fapp%2Fbar-chart.ts" rel="nofollow noreferrer">here</a></p>
  
  <p>It's a D3 chart in angular.</p>
  
  <p>The chart resizes when the window is resized, re-darwing the chart using the width of the window that is captured when the resizing happens</p>
  
  <pre><code>@HostListener('window:resize')
      onWindowResize() {
  
      this.w = this.elementView.nativeElement.offsetWidth;
      this.width = this.w - this.margin.left - this.margin.right;
  
      d3.selectAll('.bar-opacity').remove()
  
      this.initScales();
      this.drawUpdate(this.data);
  }
  </code></pre>
  
  <p>When the page first loads I don't have a width because that happens when the window is resized.</p>
  
  <p>The svg has no width when the page loads</p>
  
  <p>How can I capture the width of the svg's container when the page first loads</p>