title: TypeError: Cannot read property 'username' of undefined
body: <p>Still on learning ionic together with mysql and trying to create a login form with remote database, facing a problem that i got an error "TypeError: Cannot read property 'username' of undefined"</p>
  
  <p>Below is my code</p>
  
  <p>login.html</p>
  
  <pre><code>&lt;ion-header-bar align-title="center" class="bar-balanced"&gt;
    &lt;h1 class="title"&gt;Onseral&lt;/h1&gt;
  &lt;/ion-header-bar&gt;
  &lt;ion-view&gt;
    &lt;ion-content class="padding has-header"&gt;
      &lt;ion-list&gt;
         &lt;ion-item&gt;
           &lt;input type="text" ng-model="username" placeholder="Username"&gt;
         &lt;/ion-item&gt;
         &lt;ion-item&gt;
           &lt;input type="password" ng-model="password" placeholder="Password"&gt;
         &lt;/ion-item&gt;
       &lt;/ion-list&gt;
  
       &lt;button nav-clear class="button button-block button-balanced" ng-click="LogIn()"&gt;Login&lt;/button&gt;
    &lt;/ion-content&gt;
  &lt;/ion-view&gt;
  </code></pre>
  
  <p>controller.js</p>
  
  <pre><code>angular.module('ionicApp.controllers', [])
   .controller('AppCtrl', function($scope) {
   })
  
  .controller('LoginCtrl', function($scope, $state, $http, $ionicPopup) {
    $scope.LogIn = function() {
      var request = $http({
          method: "post",
          url: "http://www.mywebsite.com/api/login.php",
          data: {
            username: $scope.username,
            password: $scope.password
          },
          headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
        });
  
        /*Successful HTTP post request or not */
  
        request.success(function (data){
  
          if (data == '1'){
            console.log('test success');
            }
           else {
           console.log('test failed');
           console.log($scope.username);
        }
      })
    }
  });
  </code></pre>
  
  <p>app.js</p>
  
  <pre><code>angular.module('ionicApp', ['ionic','ionicApp.controllers'])
  
  .config(function($stateProvider, $urlRouterProvider) {
  
   $stateProvider
  
  .state('app', {
    url: "/app",
    abstract: true,
    templateUrl: "templates/menu.html",
    controller: 'AppCtrl'
  })
  
      .state('login', {
       url: "/login",
       templateUrl: "templates/login.html",
       controller: 'LoginCtrl'
   });
    // if none of the above states are matched, use this as the fallback
   $urlRouterProvider.otherwise('/login');
  });
  </code></pre>
  
  <p>It just cant get the username from the login.html, what am i missing here?</p>