title: Angular service, trying to read data from file (I'm using node-webkit), can't get it to work
body: <p>I've been trying for a while and looked through several answers, I can't figure out why this is not working:</p>
  
  <p>I need to share some data between controllers, so I set up a service right?
  (The data is obtained from a file, I'm using node-webkit)</p>
  
  <pre><code>.service('tagList', function() {
  
    this.getTags = function() {
      var t;
  
      fs.readFile('tags', 'utf8', function(err, data) {
        if (err) throw err;
        console.debug(data.split(','));
        t = data.split(',');
      });
  
      console.debug(t);
      return t;
    };
  
  })
  </code></pre>
  
  <p>Then in some controller I'd do</p>
  
  <pre><code>.controller('sidebarCtrl', function($scope, tagList) {
    $scope.tags = tagList.getTags();
  })
  </code></pre>
  
  <p>But tags ends up as <code>undefined</code>, the <code>console.debug</code> inside <code>readFile</code> both show t how it should be.</p>
  
  <p>But the <code>console.debug</code> outside <code>readFile</code>, shows it as <code>undefined</code>, why? If it is declared on <code>getTags</code> scope.</p>