title: Angularjs :$routeChangeStart event
body: <p>i'm newbie in angularjs how can check if user logged? i'm using sailsjs backend and angularjs front end</p>
  
  <pre><code>module.run(function ($location, $rootScope) {
        $rootScope.$on("$routeChangeStart", function (event, next, current) {
  
        });
     })
  </code></pre>
  
  <p><strong>signin.js</strong></p>
  
  <pre><code>.controller('SigninCtrl', function ($scope,$location,User,$http) {             
  
  
      $scope.signin = function(){
      var data={ email:$scope.email,password:$scope.password}
         var user=User.signin(data);
          //console.log(typeof user);
       user.success(function (data) {
                      //console.log("token signin",data);
                      var token=data.token;
                  localStorage.setItem('id_token', token);
                      $location.path("/todo");
                 })
                 .error(function (data) {
                      //Do whatever is needed
                   //console.log(data);
                 });  
          }   
  
    });
  </code></pre>
  
  <p><strong>service :User.js</strong>
      signin: function(data){</p>
  
  <pre><code>            return $sails.post('/api/auth',data);
          },
  </code></pre>