How to find children and parents of a DOM element in Angular2
<p>I know I can obtain the DOM element of a component with </p>

<pre><code>constructor(el: ElementRef){}
</code></pre>

<p>But how do I access its children (e.g. by searching by class or id) and host?</p>

<pre><code>el.nativeElement.children
el.nativeElement.parent
el.nativeElement.host
</code></pre>

<p>all don't work.</p>

<p>I've searched all over for an answer, with no luck. Thank you very much for any help.</p>

<p><strong>EDIT</strong> Thanks to yurzui's comment I realised <code>el.nativeElement.children</code> works after the component's view is initialised. However I still can't access the host element.</p>

<p>Also, as JB Nizet pointed out, it is inelegant do manipulate DOM elements in Angular2. The only thing about my DOM element I need in the component's class, though, is the element's width. If I knew how to bind this value to a class attribute, I would have solved the issue without accessing the DOM. I had previously tried something like </p>

<pre><code>&lt;div [width] = "style.width"&gt;&lt;/div&gt;
</code></pre>

<p>(<code>width</code> an attribute of the class of my component, whose view containse the above div) but I can't get it to work.</p>