Я не могу получить свойство 'left' из ngx-countdown, которое является приватным.
Я читал, что вы должны объявить свойство как общедоступное, но это только библиотека (ngx-отсчет), который я установил
Ошибка, которую я получаю:
ОШИБКА в src / app / pages / exam-level / exam-level2 / exam-level2.component.ts (129,30): ошибка TS2341: свойство left оставлено и доступно только в классе CountdownComponent.src / app / pages / exam-level / exam-level2 / exam-level2.component.ts (130,39): ошибка TS2341: свойство 'left' является закрытым и доступно только в классе CountdownComponent.
ФАЙЛ ТС
import { Component, OnInit, ViewChild } from '@angular/core';
import { Subscription } from 'rxjs';
import { Router } from '@angular/router';
import { ExamsService } from '@app/services/exams.service';
import { ExamsModel } from '@app/models/exams.model';
import { HostListener } from '@angular/core';
import { ConfirmationModalModel } from '@app/models/confirmation-modal.model';
import { CountdownComponent } from 'ngx-countdown';
@Component({
selector: 'app-exam-level2',
templateUrl: './exam-level2.component.html',
styleUrls: ['./exam-level2.component.scss']
})
export class ExamLevel2Component implements OnInit {
remainingTime: any;
seconds = CountdownComponent['left'];
public questionsListLevel2: Array<ExamsModel>;
public examLevel2ModalContent: ConfirmationModalModel;
public timeLeft: CountdownComponent["left"];
level2QuestionsSet$: Subscription;
pageTab: string;
isToggled: boolean;
status = '';
@ViewChild('countdown') counter: CountdownComponent;
resetTimer() {
this.counter.restart();
this.counter.stop();
this.counter.pause();
this.counter.resume();
}
constructor(
private router: Router,
private examsService: ExamsService,
) {
this.pageTab = "exam-level2";
}
ngOnInit() {
this.getQuestionsListPart2();
this.isToggled = false;
}
// TIMER
finishTest() {
console.log('count down', this.counter);
setTimeout(() => {
this.router.navigate(['/exam-level3']);
}
, 3000);
}
stopTimer () {
this.counter.pause();
console.log(this.counter);
// console.log(this.counter.finished)
// this.timerService.sayHello();
}
onNotify() {
console.log(this.counter.left);
this.remainingTime = this.counter.left;
this.store();
}
store(){
let key = 'Timer';
localStorage.setItem(key, this.remainingTime);
}
}
ШАБЛОН
<!-- TIMER START -->
<div class="timer-container">
<countdown #countdown [config]="{leftTime: 1800, notify: [ 1795 ]}" (finished)="finishTest()" (notify)="onNotify($event)">$!m!:$!s!</countdown>
<button (click)="stopTimer()" class="btn btn-link btn-sm">STOP</button>
<button (click)="store()" class="btn btn-link btn-sm">STORE</button>
</div>
<!-- TIMER END -->