title: How to use getElementById with *ngIf?
body: <p>I'm trying to select a div which has a *ngIf on it:</p>
  
  <pre><code>&lt;div id="explanation" *ngIf="isCorrect(option.optionValue)"&gt;
  </code></pre>
  
  <p>which returns null when I use getElementById. If I remove ngIf it works fine, but I need to use the ngIf in my app. So how do I go about selecting the div?</p>
  
  <p>EDIT: refactored code like this:</p>
  
  <pre><code>&lt;div [hidden]="!isCorrect(option.optionValue)"&gt;
    &lt;div id="explanation"&gt;
      Option {{ question.answer }} is correct because {{ question.explanation }}.
    &lt;/div&gt;
  &lt;/div&gt;
  
  
  ngAfterViewInit() {
    let itemFrom = document.getElementById('explanation');
    let itemTo = document.getElementById('question');
  }
  
  radioChange(answer) {
    this.question.selectedOption = answer;
    this.answer.emit(answer);
  
    this.moveExplanation(this.itemFrom, this.itemTo);
  }
  
  moveExplanation(from, to) {
    to.replaceWith(from);
  }
  </code></pre>
  
  <p>question and explanation are now both logged, replaceWith works, just need to remove the original explanation from underneath the correct answer and each question's explanation should move into the question box and similarly remove the explanation from underneath the correct answer.</p>