"restart" works from click event but nut from handleEvent function
Closed this issue · 2 comments
marmooli commented
I can call restart() from a button click event manually and it works, but if do the same from the handleEvent it doesn't work:
@ViewChild('cd', { static: false }) private countdown: CountdownComponent;
<countdown #cd [config]="config" (event)="handleEvent($event)">
<button (click)="onRestart()">restart
handleEvent(event){
if(event.action === 'done'){
this.countdown.restart(); // this doesn't work
}
}
onRestart(){
this.countdown.restart(); // this works!
}
cipchk commented
A temporary solution:
import { Component, ViewChild } from "@angular/core";
import { CountdownComponent, CountdownEvent } from "ngx-countdown";
@Component({
selector: "my-app",
template: `
<countdown
#cd
[config]="{ leftTime: 3 }"
(event)="handleEvent($event)"
></countdown>
`
})
export class AppComponent {
@ViewChild("cd", { static: false }) private countdown: CountdownComponent;
handleEvent(event: CountdownEvent) {
if (event.action === "done") {
setTimeout(() => {
this.countdown.restart(); // this work
})
}
}
}
cipchk commented
fixed by 11.0.2