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

Unable to use timer in Ionic code.

Open saurabhgoyal12 opened this issue 8 years ago • 2 comments

I am trying to use timer with my ionic code. Unable to do it. Below is how I am trying to do. Can you please help?

{{item.userName}}

{{item.userContact}}
{{mminutes}} minute{{minutesS}}, {{sseconds}} second{{secondsS}}

{{countdown}}

saurabhgoyal12 avatar Oct 12 '16 04:10 saurabhgoyal12

If you want autostart, remove it. Here is the code. if ($scope.autoStart === undefined || $scope.autoStart === true) { $scope.start();

in index.html:

<script src="bower_components/angular-timer/dist/angular-timer.js"></script>
<script src="bower_components/moment/min/moment.min.js"></script>
<script src="bower_components/moment/min/locales.min.js"></script>
<script src="bower_components/humanize-duration/humanize-duration.js"></script>

In apps.js angular.module('app', ['ionic', 'app.controllers', 'app.routes', 'app.services', 'app.directives', 'timer'])

In the controller I had to user $rootScope.$broadcast or getElementByTagName. I haven't had time to investigate, but I think either 'timer' directive is a sibling to the controller or parent but not a child if invoked as shown.

    $rootScope.startTimer = function() {
        $rootScope.$broadcast('timer-start');
        //document.getElementsByTagName('timer')[0].start();
        $scope.timerRunning = true;
    };

    $scope.stopTimer = function() {
        $scope.$broadcast('timer-stop');
        document.getElementsByTagName('timer')[0].stop();

wivancic avatar Nov 02 '16 02:11 wivancic

in index.html

<!--<script src="bower_components/angular-timer/app/js/_timer.js"></script>-->
    <script src="bower_components/angular-timer/dist/angular-timer.js"></script>
    <script src="bower_components/moment/min/moment.min.js"></script>
    <script src="bower_components/moment/min/locales.min.js"></script>
    <script src="bower_components/humanize-duration/humanize-duration.js"></script>

wivancic avatar Nov 02 '16 02:11 wivancic