clemdesign / angular-cd-timer Goto Github PK
View Code? Open in Web Editor NEWAngular timer component with countup, countdown, and multiple options...
License: MIT License
Angular timer component with countup, countdown, and multiple options...
License: MIT License
Hi,
First of all thank you very much for this component.
From the examples on http://angular-cd-timer.clemdesign.fr/, it is not very clear how to bind the component using ViewChild.
On the page it says, "By binding timer with @ViewChild('basicTimer'), you can control the timer."
In Angular 8, I tried the following:
@ViewChild( 'basicTimer', { static: false } ) cdTimer : CdTimerComponent;
When I try to use this.cdTimer.start()
in the code, I'm told that this.cdTimer does not exist. I'm unable to determine the exact syntax to be able to use the timer programmatically.
Thanks for your help.
import { CdTimerComponent } from 'angular-cd-timer';
@ViewChild('basicTimer', { static: true }) basicTimer: CdTimerComponent;
I have written this and declared it before ngOnInit and when I am calling the start function
this.basicTimer.start();
in OnInit and on HTML side I have written below:
<cd-timer #basicTimer format="user" autoStart="false">[hours] h [minutes] m [seconds] s</cd-timer>
but getting an error ERROR Error: Uncaught (in promise): TypeError: Cannot read property 'start' of undefined can you help me out what's the issue here.
Hello, in my project
"@angular/core": "^4.3.2",
"rxjs": "^5.4.2",
"angular-cd-timer": "1.0.0",
but when I tried to add:
**import {CdTimerModule} from "angular-cd-timer";
caught error:
index.d.ts, found version 4, expected 3, resolving symbol
Hi Team,
After Integrating the timer module, I'm getting the below error when trying to build.
My package.json is as follows:
"name": "project-angular-9",
"version": "1.0.350",
"license": "Apache",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build --prod",
"gitbuild": "ng build --prod --base-href /myproject",
"test": "ng test",
"test-ci": "TEST_CI=true ng test",
"lint": "ng lint",
"e2e": "ng e2e",
"build-prod-patch": "npm version patch && node ./replace.build.js && ng build --prod --aot --outputHashing=all --base-href=./ && node ./versioning.build.js",
"build-prod-no-patch": "node ./replace.build.js && ng build --prod --aot --outputHashing=all --base-href=./ && node ./versioning.build.js"
},
"private": true,
"dependencies": {
"@angular/animations": "9.1.1",
"@angular/cdk": "9.2.1",
"@angular/common": "9.1.1",
"@angular/compiler": "9.1.1",
"@angular/core": "9.1.1",
"@angular/forms": "9.1.1",
"@angular/localize": "9.1.1",
"@angular/platform-browser": "9.1.1",
"@angular/platform-browser-dynamic": "9.1.1",
"@angular/router": "9.1.1",
"@ng-bootstrap/ng-bootstrap": "6.0.2",
"@ng-idle/core": "^11.1.0",
"@ng-idle/keepalive": "^11.0.3",
"@ng-select/ng-select": "^4.0.4",
"@ngx-translate/core": "12.1.2",
"@ngx-translate/http-loader": "4.0.0",
"angular-cd-timer": "^1.3.0",
"angular-resize-event": "^2.0.1",
"angular-user-idle": "^2.2.4",
"axios": "^0.21.4",
"chart.js": "^2.9.4",
"chart.piecelabel.js": "^0.15.0",
"core-js": "3.6.4",
"font-awesome": "4.7.0",
"html2canvas": "^1.0.0-rc.7",
"jquery": "^3.6.0",
"jwt-decode": "^2.2.0",
"moment": "^2.29.3",
"moment-timezone": "^0.5.32",
"ng2-charts": "2.3.0",
"ng2-file-size": "0.0.4",
"ng2-slim-loading-bar": "^4.0.0",
"ngx-auto-scroll": "^1.1.0",
"ngx-autosize": "^1.8.4",
"ngx-bootstrap": "^6.1.0",
"ngx-captcha": "^8.0.1",
"ngx-chips": "^2.1.0",
"ngx-mask": "^9.1.2",
"ngx-material-timepicker": "^5.5.3",
"ngx-scrolltop": "^2.4.0",
"ngx-socket-io": "^3.2.0",
"ngx-spinner": "^9.0.2",
"ngx-toast-notifications": "^1.3.0",
"replace-in-file": "^6.1.0",
"rxjs": "6.5.5",
"rxjs-compat": "^6.6.2",
"tslib": "^1.11.1",
"web-animations-js": "^2.3.2",
"zone.js": "~0.10.3"
},
"devDependencies": {
"@angular-devkit/build-angular": "~0.901.1",
"@angular/cli": "9.1.1",
"@angular/compiler-cli": "9.1.1",
"@angular/language-service": "9.1.1",
"@types/jasmine": "3.5.10",
"@types/jasminewd2": "2.0.8",
"@types/node": "13.7.6",
"codelyzer": "^5.2.1",
"jasmine-core": "3.5.0",
"jasmine-spec-reporter": "4.2.1",
"karma": "^4.4.1",
"karma-chrome-launcher": "3.1.0",
"karma-cli": "2.0.0",
"karma-coverage-istanbul-reporter": "2.1.1",
"karma-jasmine": "3.1.1",
"karma-jasmine-html-reporter": "1.5.2",
"prettier": "2.0.4",
"protractor": "5.4.3",
"ts-node": "8.6.2",
"tslint": "6.0.0",
"typescript": "^3.8.3",
"yarn": "1.22.4"
}
}
Angular version installed is
Can you please assist with what is wrong? Also, let me know if any other details is required.
in my component, I have referenced it as
import { CdTimerComponent } from 'angular-cd-timer';
...
export class MyComponent implements OnInit {
appsettings: any = AppSettings;
//more declarations
@ViewChild('votingTimer') votingTimer: CdTimerComponent;
Hi, I need help with something. I do not want the timer to autostart, I just want it to start after pressing a key (I already have a method for that).
I have set the autostart
property to false
, but that hides the timer completely, and I want it shown but set to 00:00:00.
I have also tried using the stop()
method on ngOnInit{}
, but I'm getting this error: Property 'ngOnInit' in type 'CountdownComponent' is not assignable to the same property in base type 'OnInit'.
Code:
<p><strong>Time:</strong> <cd-timer #basicTimer format="hms"></cd-timer></p>
@ViewChild('basicTimer')
ngOnInit(basicTimer:any): void {
basicTimer.stop();
}
How can I achieve this?
Thanks in advance!
Timer does not work if we set [autostart]="false", and try to start the timer by:
import { CdTimerComponent } from 'angular-cd-timer';
@ViewChild('basicTimer', { static: false }) private countUp: CdTimerComponent;
this.countUp.start();
It returns the error: TypeError: Cannot read property 'start' of undefined
Is there anything I am missing here?
In my application, I am using a two timer
Elapsed time: <cd-timer [startTime]="appt.elapsedTime" format="ms">
Remaining time: <cd-timer [countdown]="true" [startTime]="appt.remainingTime"
(onTick)="onTimeChange($event, appt)" format="ms">
I am using this in for loop
Did anything I missed?
I get that error in browser console
ERROR TypeError: Cannot read property 'nodeValue' of undefined at CdTimerComponent.push../node_modules/angular-cd-timer/cd-timer.js.CdTimerComponent.ngAfterViewInit (cd-timer.js:20)
here is my code:
<cd-timer format="hms"></cd-timer>
Hi Team,
This issue can be easily reproduced in firefox browser. Just open http://angular-cd-timer.clemdesign.fr/ link in two or three tabs of firefox browser. Under basic example, click the start button visiting all tabs and stay in the last tab for a while. Note down the seconds elapsed and then switch to the first tab, you will see that even-though we have started first in first tab, it is lagging behind the last tab which was active for a while.
Thanks,
Hemant.
angular 8 support please!
and install document
I am starting the timer, now I want to call method on a specific tick count how can I do that. Can I call a method or generate an event on specific tick count. I think I have to continuous get the tick count value and call a method when the specific tick count value comes. Any help on how to do it?
Hi,
There is a 1-second lag when the timer starts showing the text.
It would be great to render text immediately when all other content shows :)
Here is one line fix for this problem. I already did it.
Should I make a PR? Or maybe you have a reason for this 1-second lag? :)
How do we import this module in the project ?
The timer runs perfectly when we continuously use the device but when we keep the device Idle for some time timer stops and does not run.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.