title: How to call "Angular JS" service method using string variable
body: <p>is there anyway to call angular service using string variable</p>
  
  <pre><code>$scope.serviceList=["yearDetails","monthDetails","dayDetails"];
  
  //controller
  $scope.getDetails=function(type,index){
  
      if(type==$scope.serviceList[index]){
  
      // if i will call like this yearDetails.query(function(data){}); it is working
      //here i am getting "yearDetails"
       $scope.serviceList[index].query(function(data){
              console.log(data);
       });
      }
  }
  
  //service
  .factory('yearDetails', function($resource){
             return $resource('/getyearDetails', {}, {
                 query: { method:'POST', params:{}, isArray:false }
     });
  })
  .factory('monthDetails', function($resource){
             return $resource('/getmonthDetails', {}, {
                 query: { method:'POST', params:{}, isArray:false }
     });
  })
  .factory('dayDetails', function($resource){
             return $resource('/getdayDetails', {}, {
                 query: { method:'POST', params:{}, isArray:false }
     });
  })
  </code></pre>