title: Event when component's view updated in Angular2
body: <p>I'm trying to combine Angular2 with jQuery + <a href="https://harvesthq.github.io/chosen/" rel="nofollow noreferrer">Chosen</a> plugin. It's basically an extension of the answer to this question <a href="https://stackoverflow.com/questions/30623825/how-to-use-jquery-with-angular2">How to use jQuery with Angular2?</a>.</p>
  
  <p>I want to dynamically update items displayed in Chosen select box. Chosen has <code>chosen:updated</code> event design for this but I need to trigger it after component's view has been updated because Chosen just looks at the <code>&lt;option&gt;</code> elements and generates its content based on them.</p>
  
  <p>You can see live "working" demo: <a href="http://plnkr.co/edit/42RaphKFHPNrNYuWlrbe?p=preview" rel="nofollow noreferrer">http://plnkr.co/edit/42RaphKFHPNrNYuWlrbe?p=preview</a></p>
  
  <p>This means that if I do:</p>
  
  <pre><code>this.items.push('Another #' + this.items.length);
  jQuery(this.el.nativeElement).find('select').trigger("chosen:updated");
  </code></pre>
  
  <p>It won't do anything because the view hasn't been updated after calling <code>this.items.push()</code>.</p>
  
  <p>I tried wrapping <code>trigger("chosen:updated")</code> with <code>setTimeout</code> to call it asynchronously which I thought could help.</p>
  
  <pre><code>this.items.push('Another #' + this.items.length);
  setTimeout(() =&gt; {
      jQuery(this.el.nativeElement).find('select').trigger("chosen:updated");
  });
  </code></pre>
  
  <p>It seems like it does help but I'm wondering if this is the correct approach or just coincidence that this works?<br>
  I thought there could be some event on components called after their view has been updated but it seem like none of them do what I need.</p>
  
  <p>Edit: The same problem is very well described in another question: <a href="https://stackoverflow.com/questions/34827334/triggering-angular2-change-detection-manually">Triggering Angular2 change detection manually</a>.</p>
  
  <p>Updated working demo: <a href="http://plnkr.co/edit/w7hHmUaD9Eqq3ffQueXp?p=preview" rel="nofollow noreferrer">http://plnkr.co/edit/w7hHmUaD9Eqq3ffQueXp?p=preview</a></p>