title: Angular 5 - lifecycle hook in directive
body: <p>I am new to Angular 5.<br>
  I have created the directive for the external JS library.<br>
  But in the same directive, I am binding value to the attribute.</p>
  
  <p>I am trying to sue <code>ngAfterViewInit</code> to detect whether all the values are bound to the attribute and then call the jQuery plugin.</p>
  
  <p>But I have find life cycle hook only for the component. Can I use those in directive? Is that a good choice?</p>
  
  <pre><code>&lt;div *ngFor="let item of easypiechartOptions"
      [option]="item"
      appEasyPieChart
      [attr.data-percent]="item.percent"&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>If I don't use <code>ngAfterViewInit</code>, then when I call jQuery plugin, the values are not bound.<br>
  If I use that, the attribute values are ready when I call the jQuery plugin.</p>