angular-timer
angular-timer copied to clipboard
Timer not showing
I have loaded the angular-timer.min.js
. I have got a <timer />
and $scope.$broadcast('timer-start');
in my controller, hoping to start it, but nothing shows up...
Have I missed something?
Did you also install some of the dependencies mentioned in the requirements - https://github.com/siddii/angular-timer#requirements ?
Definitely, I have also got the moment.min.js
, locales.min.js
and humanize-duration.js
Could you please share your code as a plunkr or something?
It is in an ionic app actually, not sure if I can put it on there...
Do I have to inject any additional modules to get it to work actually?
Currently I basically have
.controller('MyController', ['$scope', function($scope) { $scope.$broadcast('timer-start'); }])
Yes, angular-timer
.
I see, so now I changed it to
.controller('MyController', ['$scope', 'angular-timer', function($scope, angular-timer) { $scope.$broadcast('timer-start'); }])
but I get a Uncaught SyntaxError: Unexpected token function
for that line with angular-timer
...
Thats a wrong injection. It should be injected as a module where you inject ionic
modules.
Sorry...my bad... now I removed my previous incorrect injection, and went to modify this:
angular.module('starter', ['ionic', 'starter.controllers', 'starter.services', 'angular-timer'])
But I get this
Uncaught Error: [$injector:modulerr] Failed to instantiate module starter due to: Error: [$injector:modulerr] Failed to instantiate module angular-timer due to: Error: [$injector:nomod] Module 'angular-timer' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument.
Can you create a plunkr? Its hard to see without all the pieces.
My bad again... timer
should be injected instead of angular-timer
? I used timer
instead and previous errors are all gone, although nothing is shown, still...
I only get Error: [$injector:unpr] Unknown provider: timerProvider <- timer <- MyController
this time, never seen this before though...
Do you still have timer
injected as a service to your controller?
Yes
Timer module don't expose any service at this point. Can you try removing it?
Did this ever get anywhere? I have a similar issue...
I am also Facing simillar issue
@saeed68gm , got it to work.
Dont include it as a dependency in any controller. Just add it on the module.
angular .module('DemoApp', [ 'ngAnimate', 'timer' ])
Thanks for the answer @Thomasforweb .
I tried it and it didn't really work for me. My module got undefined. Although I only added timer to public->controllers->mycontroller.js
Is this because this will create a new angular module instead of using the previous created one?
Here is the code for controller after adding timer:
var apptyme = angular.module('mean.tyme', ['timer']);
apptyme.controller('TymeController', ['$scope', '$location', 'Global', 'Tyme', 'MeanUser',
function($scope, $location, Global, Tyme, MeanUser) {
$scope.global = Global;
$scope.package = {
name: 'tyme'
};
$scope.startTimer = function() {
console.log('starting timer')
$scope.$broadcast('timer-start');
$scope.timerRunning = true;
};
}]);
After I add timer my page does not even load and it goes back to the original mean.io home page.
The code for public services:
'use strict';
var apptyme = angular.module('mean.tyme');
apptyme.factory('Tyme', ['$resource',
function($resource) {
// console.log('services resource:'+ $resource);
return $resource('api/tyme/:tymeId', {
tymeId: '@_id'
});
}
]);
For public routes:
'use strict';
var apptyme = angular.module('mean.tyme');
apptyme.config(['$viewPathProvider', function($viewPathProvider) {
$viewPathProvider.override('system/views/index.html', 'tyme/views/index.html');
}])
.config(['$controllerProvider', function($controllerProvider) {
$controllerProvider.allowGlobals();
}]);
@saeed68gm Can you create plunker?
Hey @Thomasforweb here is the link to the plunker.
This is only the public folder of my package in mean.io: https://plnkr.co/edit/5nxxGDDJbFUsUTHyfsBZ
I tried following this tutorial: http://storybynumbers.com/meanio-asset-management.html
I added these three lines to config/assets.js:
"bower_components/moment/moment.js",
"bower_components/humanize-duration/humanize-duration.js",
"bower_components/angular-timer/dist/angular-timer.min.js",
And this line to tyme/app.js:
Tyme.angularDependencies(['timer']);
Now when I try to inject the dependency in my package's public controller:
var apptyme = angular.module('mean.tyme');
apptyme.controller('TymeController', ['$scope', '$location', 'Global', 'Tyme', 'MeanUser', 'timer',
function($scope, $location, Global, Tyme, MeanUser, timer) {
I get the following error:
Error: $injector:unpr Unknown Provider Unknown provider: timerProvider <- timer <- TymeController
please was this issue ever fixed?
Same issue also occurred for me. is there any possible solution. I have a condition, based on one condition timer start working, but on another condition timer is not working.