I am new to Angular 5.
I have created the directive for the external JS library.
But in the same directive, I am binding value to the attribute.
I am trying to sue ngAfterViewInit
to detect whether all the values are bound to the attribute and then call the jQuery plugin.
But I have find life cycle hook only for the component. Can I use those in directive? Is that a good choice?
<div *ngFor="let item of easypiechartOptions"
[option]="item"
appEasyPieChart
[attr.data-percent]="item.percent">
</div>
If I don't use ngAfterViewInit
, then when I call jQuery plugin, the values are not bound.
If I use that, the attribute values are ready when I call the jQuery plugin.
implements AfterViewInit
and declare yourngAfterViewInit()
function. – Unconformable