vendredi 29 mai 2015

How to Write Controller Time Variables for Angular Timer ?

Iam Using http://ift.tt/1jw86ZJ which is working good with Some Constant Formatting like

<timer interval="1000">{{hours}} hour{{hoursS}}, {{minutes}} minute{{minutesS}}, {{seconds}} second{{secondsS}}.</timer> 

But when trying to load hour and minutes ,seconds from Controller it is not happening

Code Follows

My Controller :-

 Mymodule.controller('timingcontroller'),[],

    function($scope,$rootScope,moment){
       $scope.timings = function () {

            $scope.timeZone='America/Denver';
            var TimeZoneHrs=moment().tz($scope.timeZone).format('HH');//Returns HH:mm 24 Hour Format
            var TimeZoneMinutes=moment().tz($scope.timeZone).format('mm');
            var TimeZoneSeconds=moment().tz($scope.timeZone).format('ss');

             $scope.TimeZoneHrs=TimeZoneHrs;
            $scope.TimeZoneMinutes=TimeZoneMinutes;
            $scope.TimeZoneSeconds=TimeZoneSeconds;

        };
      }

Angular View :-

<section  data-ng-controller="timingcontroller"  data-ng-init ="timings()">
        <timer >{{TimeZoneHrs}} hour{{TimeZoneHrsS}}, {{TimeZoneMinutes}}  minute{{TimeZoneMinutesS}}, {{TimeZoneSeconds}} seconds{{TimeZoneSecondsS}}</timer>

    </section>

Output:- hour, minute, seconds . But not the Scope related data as Timer

Iam Pretty New to this Timer Concept Could You Please Let me Know How can I achieve that ?

Thanks in Advance

Aucun commentaire:

Enregistrer un commentaire