title: Alternative to elementRef.nativeElement.id
body: <p>I know it is not recommended to use replace <code>elementRef.nativeElement</code> and it is recommended to replace iT with some tag of <code>ViewChild</code> or something of the sort. I wonder how can I use these tags to replace the use of it, when I have a native element of a general type. I need to access the id of a general element of an unknown type:</p>
  
  <pre><code>elmentRef.nativeElement.id
  </code></pre>
  
  <p>my relevant package.json:</p>
  
  <pre><code>"@angular/common": "4.2.5",
  "@angular/compiler": "4.2.5",
  "@angular/core": "4.2.5"
  </code></pre>
  
  <p>I am trying to replace this code which is a parent for may others on my library because I am getting:</p>
  
  <pre><code>import { ElementRef } from '@angular/core';
  
  export abstract class IdentityComponent {
      id = '';
  
      constructor(protected el: ElementRef) {
          if (el) {
              this.id = el.nativeElement.id;
          }
      }
  }
  </code></pre>