javascript - how to set config inside of controller -


i wrote provider in application below;

module.provider('calculatetime', function() {       this.$get = function() {         var seconds = this.seconds;         var minutes = this.minutes;         var hours = this.hours;         var day = this.day;          return {              toseconds: function(){                  return math.round(seconds);             },                    tominutes: function(){                 return math.round(minutes);             },              tohours: function(){                 return math.round(hours);              },                    todays: function(){                 return math.round(day);             },              exactdate: function(){                   return math.floor(hours%24)+":"+ math.floor(minutes%60)+":"+ math.floor(seconds%60);                           }             }     };      this.settime = function(milis) {          this.milis = milis;         this.seconds = this.milis/1000;         this.minutes = this.seconds/60;         this.hours = this.minutes/60;         this.day = this.hours/24;     }; }); 

and want set config inside of controller ( after finished preparation , set up). tried follows;

  module.controller('resultcontroller',function($scope,$data,calculatetime){       var date = $data.post.date;       given.setdate(date.selectedyear,date.selectedmonth,date.selectedday);       var =  new datetime();      var diff = now.compare(given);       // config here              module.config(function(calculatetimeprovider){         calculatetimeprovider.settime(diff);     });       settimeout(function() {       $scope.$apply(function() {         $scope.result =  calculatetime.todays() + " days " +  calculatetime.exactdate();        });      }, 100); 

$scope.result become null , nothing come out. know i'm wrong in usage , still don't know correct way use whether service or provider or factory. please tell me correct ways of setting , retrieving.

you can not configure module after bootstrapping phase. configuration needs happen before. have outside of controller's scope.


Comments

Popular posts from this blog

c++ - QTextObjectInterface with Qml TextEdit (QQuickTextEdit) -

javascript - angular ng-required radio button not toggling required off in firefox 33, OK in chrome -

xcode - Swift Playground - Files are not readable -