siddii / angular-timer

re-usable/inter-operable AngularJS timer directive ⛺
http://siddii.github.io/angular-timer/
MIT License
791 stars 939 forks source link

Timer not showing #208

Open ghost opened 9 years ago

ghost commented 9 years ago

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?

siddii commented 9 years ago

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

ghost commented 9 years ago

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

siddii commented 9 years ago

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

ghost commented 9 years ago

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

siddii commented 9 years ago

Yes, angular-timer.

ghost commented 9 years ago

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

siddii commented 9 years ago

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

ghost commented 9 years ago

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.

siddii commented 9 years ago

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

ghost commented 9 years ago

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

siddii commented 9 years ago

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

ghost commented 9 years ago

Yes

siddii commented 9 years ago

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

saeed68gm commented 8 years ago

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

Thomasforweb commented 8 years ago

I am also Facing simillar issue

Thomasforweb commented 8 years ago

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

saeed68gm commented 8 years ago

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 commented 8 years ago

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();
  }]);
Thomasforweb commented 8 years ago

@saeed68gm Can you create plunker?

saeed68gm commented 8 years ago

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 commented 8 years ago

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

vcnwafor commented 4 years ago

please was this issue ever fixed?

karthikn2510 commented 4 years ago

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.