Comments (5)
I understand the need here. However, its a very thin line on deciding where this method can go. We can argue that the callee should be able to do this from its end or probably the concern of directive itself.
I am thinking out loud in a broader term here.. may be the best thing to do is probably make it generic, like adding methods on other attributes as well like.. resetInterval(intervalTime), resetCountdown(countdown), resetStartTime(startTime) etc.
Those methods can reset the value & timers also.
Let me know what you think.
from angular-timer.
I hadn't thought in the others methods,that will be useful too , I like your idea :)
from angular-timer.
+1
Any news on this?
from angular-timer.
Sorry I haven't had a chance to look at this. I will take a look at this as my next thing as soon as possible.
from angular-timer.
The code to subtract seconds from the startTime is pretty simple. I managed to create a "count up" timer by just adding an attribute similar to countdown and then:
$scope.addCUSeconds = $element[0].addCUSeconds = function(millisToRemove){
$scope.startTime = new Date($scope.startTime.getTime() - millisToRemove)
$scope.$digest();
if (!$scope.isRunning) {
$scope.start();
}
};
$scope.$on('timer-set-cu-seconds', function (e, millis) {
$timeout(function (){
$scope.addCUSeconds(millis);
});
});
Naming could probably be improved. The big problem I see is that because you are using controller rather than link (postlink) you can't have something like:
timer(start-time="{{myStartTime}}", auto-start="false", interval='1000') {{mminutes}}:{{sseconds}}
I tried messing around with changing start-time to & or @ scoping, but the init of startTime in $scope.start() pretty much kills it.
from angular-timer.
Related Issues (20)
- Timer value is not updated? HOT 1
- Using both start-time and end-time HOT 3
- Timer is working in wrong way with exactly one year gap HOT 1
- Countdown not working with low value
- Missing $scope reference?
- Add timer in list: "timeoutId is not defined" error message HOT 3
- Customise countdown visualization HOT 2
- $scope.$broadcast('timer-reset') restarts all available timers in the scope when using ng-repeat
- end-time counting up instead of counting down HOT 1
- Is it support angular2 & 4 version for dynamic value support?
- Regular Expression Denial of Service issue with momentjs > v2.11.2
- finish-callback not found
- Can't bind data to countdown attribute HOT 1
- start-time setting HOT 1
- When ticks whole div's background color changed to white, only happens on safari
- Count down does not stop even after the timer-stop is triggered
- Set interval in Chrome console
- Is this plugin available in Angular 2 or above angular version?
- Changing CSS when seconds > x
- An old vulnerable version of "bootstrap" is used in the repo
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from angular-timer.