angular-timer icon indicating copy to clipboard operation
angular-timer copied to clipboard

Timer not showing

Open ghost opened this issue 9 years ago • 23 comments

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?

ghost avatar Aug 18 '15 13:08 ghost

Did you also install some of the dependencies mentioned in the requirements - https://github.com/siddii/angular-timer#requirements ?

siddii avatar Aug 18 '15 13:08 siddii

Definitely, I have also got the moment.min.js, locales.min.js and humanize-duration.js

ghost avatar Aug 18 '15 13:08 ghost

Could you please share your code as a plunkr or something?

siddii avatar Aug 18 '15 13:08 siddii

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'); }])

ghost avatar Aug 18 '15 13:08 ghost

Yes, angular-timer.

siddii avatar Aug 18 '15 14:08 siddii

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...

ghost avatar Aug 18 '15 14:08 ghost

Thats a wrong injection. It should be injected as a module where you inject ionic modules.

siddii avatar Aug 18 '15 14:08 siddii

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.

ghost avatar Aug 18 '15 14:08 ghost

Can you create a plunkr? Its hard to see without all the pieces.

siddii avatar Aug 18 '15 14:08 siddii

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...

ghost avatar Aug 18 '15 14:08 ghost

Do you still have timer injected as a service to your controller?

siddii avatar Aug 18 '15 14:08 siddii

Yes

ghost avatar Aug 18 '15 14:08 ghost

Timer module don't expose any service at this point. Can you try removing it?

siddii avatar Aug 18 '15 16:08 siddii

Did this ever get anywhere? I have a similar issue...

saeed68gm avatar Feb 22 '16 03:02 saeed68gm

I am also Facing simillar issue

Thomasforweb avatar Feb 27 '16 13:02 Thomasforweb

@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' ])

Thomasforweb avatar Feb 28 '16 08:02 Thomasforweb

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?

saeed68gm avatar Feb 28 '16 15:02 saeed68gm

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 avatar Feb 29 '16 15:02 saeed68gm

@saeed68gm Can you create plunker?

Thomasforweb avatar Feb 29 '16 17:02 Thomasforweb

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

saeed68gm avatar Mar 01 '16 05:03 saeed68gm

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

saeed68gm avatar Mar 02 '16 05:03 saeed68gm

please was this issue ever fixed?

vcnwafor avatar May 27 '20 13:05 vcnwafor

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.

karthikn2510 avatar Aug 06 '20 05:08 karthikn2510