title: Angular 2 Get width of a div
body: <p>I've looked at numerous posts but none quite do what I want it to do.
  I have a table which goes outside the width of the page and for various reasons I need to get it's width.</p>
  
  <p>I used:</p>
  
  <pre><code>@ViewChild('tableToMeasure') elementView: ElementRef;
  </code></pre>
  
  <p>And then put #tableToMeasure on the table. However this seems to error:</p>
  
  <pre><code>ERROR Error: Uncaught (in promise): TypeError: Cannot read property 'nativeElement' of undefined
  </code></pre>
  
  <p>Even though this works on and only on the parent div of the page.</p>
  
  <p>Any ideas? I need to get it's width on both page load and page resize and change another divs width to be the same value.</p>