Home:ALL Converter>How do i call nested methods of dependency injected service from a directive's controller?

How do i call nested methods of dependency injected service from a directive's controller?

Ask Time:2016-04-05T02:51:57         Author:JsLearner

Json Formatter

function myController($scope,helperService)
  {

   function getFormattedDT() {
      var localDate = "2016-04-04 12:55:55";
      var inputDate = helperService.parsedDate(helperService.formatDate(localDate));
    } 
     getFormattedDT();
   }

I am getting the error as "TypeError : helperService.formatDate is not a function".

(function (myApp)
 {
    myApp.service('helperService',['$http','$q','$sce','miscService', function($http,$q,$sce,'miscService') {

    function formatDate(dateTime) {
        return ....
    }

    function parsedDate(date) {
       return ....
     }

}(angular.module('myApp')

But if i keep the function in the myController, then it works well. How do i call nested methods in injected dependencies of angular.

Author:JsLearner,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/36410575/how-do-i-call-nested-methods-of-dependency-injected-service-from-a-directives-c
yy