Home > Mobile >  ngx-countdown Notify is not working in angular
ngx-countdown Notify is not working in angular

Time:12-11

When 1 hour is remaining it sholud call notify For that I set 3600 second in notify.but it's not working

html file code:

<countdown #cd [config]="remainingduration" (event)="handleCountDown($event)"></countdown>

ts file code:

@ViewChild('cd', { static: false }) public countDownTime: CountdownComponent;


      timeCountdown(time){
            if (time > 3600) {
              this.remainingduration = { leftTime: time, format: 'HH:mm:ss', notify: [3600] };
              this.showHours =true
            }
      } 



 handleCountDown(event) {
        console.log(event)
    }

CodePudding user response:

This example worked for me as you expect:

import { Component } from '@angular/core';

@Component({
  selector: 'my-app',
  template: `
  <countdown [config]="timerConfig" (event)="handleCountDown($event)"></countdown>
  `,
})
export class AppComponent {
  timerConfig = { leftTime: 3610, notify: [3600] };
  
  handleCountDown(event) {
    console.log(event);
  }
}

After 10 seconds the event of "action: notify" was fired

CodePudding user response:

Try this:

import { Component, ViewChild } from '@angular/core';
import { CountdownComponent } from 'ngx-countdown';
@Component({
  selector: 'my-app',
  template: `
  <countdown #cd  [config]="{leftTime: timeData, notify: [ 3600]}" (event)="handleEvent($event)"></countdown>
  `,
})
export class AppComponent {
  @ViewChild('cd', { static: false }) private countdown: CountdownComponent;
  timeData = '3605';
  constructor() {}

  handleEvent(event) {
    console.log(event)
  }
}
  • Related