title: AngularJS : difference between $rootScope.Controller and Service
body: <p>I am trying to understand Angularjs behaviors.
  I am building a web-app, and I want the CurrentUser's info be shared among all the app components. To do that, I have created a <code>CurrentUserController</code> bound to $rootScope. This controller is used by a <code>user</code> directive utilized in the <code>body</code> html element, so that it is globally accessible and it's created just one time.</p>
  
  <pre><code>app.controller('CurrentUserController', function ($rootScope) 
    {
     // initialization
     $rootScope.userCtrl = self; //&lt;- MAKE IT GLOBAL
     this.islogged=false;
     this.name="";
     var self = this;
     // functions
     this.isLogged = function() 
          { return self.islogged; };
  
     this.setLoggedIn = function(credentials) 
          { self.islogged = true; }; 
  
     this.setLoggedOut = function() 
          { self.islogged = false; };                 
    }
  );
  
  app.directive('currentUser', function() {
    return {
      controller:'CurrentUserController'
    };
   })
  </code></pre>
  
  <p>and then my html page</p>
  
  <pre><code>&lt;html&gt;
  ...
  &lt;body current-user&gt; 
  ...
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>However I read that <code>Services</code> should be used to share data between controllers, since they are <em>singleton</em>. 
  So my question is:
  <strong>is my approach wrong, or it is equivalent as I utilized services?</strong></p>
  
  <p>Moreover, right now I can utilize the directive <code>ng-switch</code> calling <code>$rootScope.userCtrl</code> functions, like this:</p>
  
  <pre><code>&lt;div id="nav-right-side" class="navbar-right" ng-switch on="userCtrl.isLogged()"&gt;
              &lt;div ng-switch-when="false"&gt;
                  &lt;login-button&gt;&lt;/login-button&gt;
              &lt;/div&gt;
          &lt;div ng-switch-when="true"&gt;
                  &lt;loggedin-button&gt;&lt;/loggedin-button&gt;
              &lt;/div&gt;                      
  
          &lt;/div&gt;
  </code></pre>
  
  <p>If I utilize services, would I still be able to do that?
  Thank you</p>