title: Angular parent child scope with service
body: <p>I'm stuggling with some concepts of Angular, in particular the flow of variable and scope.</p>
  
  <p>What I'm trying to do is to set a variable in a child controller and pass it to a parent scope. Consider this simple example:</p>
  
  <pre><code>module.controller('childController', childController);
  function childController($scope,$http,$window, hexafy) {
      $scope.hex = hexafy.myFunc(17);      
  }
  
  module.controller('parentController', parentController);
  function parentController($scope, hexafy) {
  
  }
  
  module.service('hexafy', function() {
      this.myFunc = function (x) {
          return x.toString(16);
      }
  });
  </code></pre>
  
  <p>Then my mark-up is as follows:</p>
  
  <p></p>
  
  <pre><code>{{hex}}
  
  &lt;section data-ng-controller="listingsViewController"&gt;....&lt;/section&gt;
  </code></pre>
  
  <p></p>
  
  <p>The calculation is handled by the child controller but as you can see I want to pass the variable to the 'parent'. I have read about 'parent' scope but I understand that this is not best practise so I'm attempting to use a service. Where am I going wrong?</p>