title: How to return value from service to controller in Angularjs
body: <p>i have a service as below</p>
  
  <pre><code>module.service('translationService', [
      "$resource",
      function($resource) {
          var This = this;
          This.params = 'HELLO';
          This.getTranslation = function() {
              var languageFilePath = 'sample.json';
              //return languageFilePath;
              $resource(languageFilePath).get(function(data) {
                  var temp = "";
                  if (This.params != "") {
                      angular.forEach(data, function(key, value) {
                          if (value == This.params)
                              temp = key;
                      });
                  } else {
                      This.translation = "Pls input key";
                  }
                  This.translation = temp;
                  return temp;
              });
          }
      }
  ]);
  </code></pre>
  
  <p>In controller i am calling service,</p>
  
  <pre><code> This.translate = translationService.getTranslation();
  </code></pre>
  
  <p>Problem is when i debug temp has value , but when i return value becomes null. May be its inside one more function <code>.get()</code> and return is losing scope. But if I return <code>languageFilePath</code> as commented above (<code>//return languageFilePath;</code>), value is passing to controller. </p>
  
  <p>Please help me how to return value.</p>