Запрашивать DOM в Angular не рекомендуется. Вам нужно сделать это угловым способом:
Сначала вам нужно использовать переменную ссылки на шаблон, чтобы вы могли ссылаться на них в своем компоненте. Ссылочные переменные шаблона имеют префикс #.
<div class="loader">
<div class="loader-border">
<div class="progress" [ngStyle]="{'width': '0%'}" #progress>
<div class="progress-text">
<p id="count" #count><p>
</div>
</div>
</div>
</div>
Теперь в вашем компоненте вам нужно импортировать ViewChild и ElementRef и использовать их, как показано ниже:
progres: any;
width: string;
count: any;
tween: any;
newPercent: any;
@ViewChild('count') count: ElementRef;
@ViewChild('progress') count: ElementRef;
constructor() {}
ngOnInit() {
this.progres = this.progress.nativeElement;
this.count = this.count.nativeElement;
this.tween = new TweenLite(this.progres, 10, {
width: '100%',
ease: Linear.easeNone,
onUpdate: () => {
this.newPercent = (this.tween.progress() * 100).toFixed();
this.count.nativeElement.innerHTML = this.newPercent + '%');
}
});
}