title: AngularJs + php authentication
body: <p>Hi i started learning AngularJs and now im trying to do my Login module using angular and php, but i have some issues. I have watched alot tutorials but none of them was helpful in my case, so here is what i have: controllers.js:  </p>
  
  <pre><code>var controllers = angular.module('controllers', []);     
  
  controllers.controller('loginController', ['$scope', '$http', 'UserService', function(scope, $http, User) {
  scope.main = [
      {username: '', password: ''}
  ]
  
  scope.login = function(){
      var config = {
          url: '../auth/login.php',
          method: 'POST',
          data: {
              username: scope.main.username,
              password: scope.main.password
          },
          headers: {'Content-Type': 'application/x-www-form-urlencoded'}
      }
  
      $http(config)
      .success(function(data,status,headers,config){
          if(data.status){
              //succefull login
              User.isLogged = true;
              User.username = data.username;
          }
          else{
              User.isLogged = false;
              User.username = '';
          }
      })
      .error(function(data,status,headers,config){
          User.isLogged = false;
          User.username = '';
      });
  }
  }])
  </code></pre>
  
  <p>auth.js:</p>
  
  <pre><code>var services = angular.module('services', []);
  
  services.factory('UserService', [function(){
      var sdo = {
          isLogged: false,
          username: ''
      };
      return sdo;
  }]);
  </code></pre>
  
  <p>login.php:</p>
  
  <pre><code>$username = $_POST['username'];
  if($username){
      return "Logged";
  }else{
      return false;
  }
  </code></pre>
  
  <p>and the html:</p>
  
  <pre><code>&lt;div class="col-xs-12" id="loginCol" ng-controller="loginController"&gt;
     &lt;form ng-submit='login()' name="form" novalidate&gt;
        &lt;div class="form-group"&gt;
           &lt;label for="username" class="sr-only"&gt;Username&lt;/label&gt;
           &lt;input type="text" ng-model="scope.main.username" class="form-control" id="username" placeholder="Име..." /&gt;
           &lt;label for="password" class="sr-only"&gt;Password&lt;/label&gt;
           &lt;input type="password" ng-model="scope.main.password" class="form-control" id="password" placeholder="Парола..." /&gt;
        &lt;/div&gt;
  
        &lt;div class="form-group pull-right"&gt;
           &lt;button type="button" class="btn btn-primary"&gt;Login&lt;/button&gt;
           &lt;button type="button" class="btn btn-default"&gt;Register&lt;/button&gt;
        &lt;/div&gt;
     &lt;/form&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>In this case i want just if user type something in the username input and hit the login button and on successful call of login.php to return some message. The problem is that code written like that got error "'loginController' is not a function, got undefined" how to fix it?</p>