title: AngularJs: pass $scope variable with service
body: <p>I have two controllers and in one of them I declared a $scope variable that I would like visible in the second controller.</p>
  
  <p><strong>First controller</strong></p>
  
  <pre><code>app.controller('Ctrl1', function ($scope) {
      $scope.variable1 = "One";
  });
  </code></pre>
  
  <p><strong>Second Controller</strong></p>
  
  <pre><code>app.controller('Ctrl2', function ($scope, share) {
     console.log("shared variable " + share.getVariable());
  });
  </code></pre>
  
  <p>I researched the best Angular approach and I found that is the use of service. So I added a service for <code>Ctrl1</code></p>
  
  <p><strong>Service</strong></p>
  
  <pre><code>.service('share', function ($scope) {
      return {
          getVariable: function () {
              return $scope.variable1;
          }
      };
  });
  </code></pre>
  
  <p>This code return this error: </p>
  
  <pre><code>Unknown provider: $scopeProvider &lt;- $scope &lt;- share
  </code></pre>
  
  <p>So my question is: is possible share $scope variable between controllers? Is not the best Angular solution or i'm missing something?</p>
  
  <p>Sorry for my trivial question but I'm an Angular beginner.</p>
  
  <p>Thanks in advance</p>
  
  <p>Regards</p>