title: angular.js:12520 TypeError: Cannot read property 'post' of undefined
body: <p>I am very much new to angularjs, i have look many webpages but not get any concrete solutions. </p>
  
  <p>What i am trying to achieve is i am creating one factory service to authenticate the user. After successful authentication it navigate to dashboard page. </p>
  
  <p>i am getting the following error:</p>
  
  <pre><code>angular.js:12520 TypeError: Cannot read property 'post' of undefined
      at Object.factory.authentication (login.html:74)
      at r.$scope.loginCall (login.html:65)
      at fn (eval at compile (angular.js:13365), &lt;anonymous&gt;:4:218)
      at e (angular.js:23613)
      at r.$eval (angular.js:16052)
      at r.$apply (angular.js:16152)
      at HTMLInputElement.&lt;anonymous&gt; (angular.js:23618)
      at HTMLInputElement.dispatch (jquery-1.9.1.min.js:3)
      at HTMLInputElement.v.handle (jquery-1.9.1.min.js:3)
  </code></pre>
  
  <p>My Html Code is :</p>
  
  <pre><code>    &lt;div ng-app="loginFormApp" ng-controller="loginFormCtrl"&gt;
  
  &lt;form method="post" action="" id="login_form" class="row"&gt;
                              &lt;input type="text" placeholder="Login ID" ng-model="loginId" &gt;
                              &lt;input type="password" placeholder="Password" ng-model="password" &gt;
                              &lt;input type="button" class="btn btn-theme" ng-click="loginCall()" value="Login"&gt;
                              &lt;input type="button" class="btn btn-theme" ng-click="loginCall()" value="Register Here"&gt;
                          &lt;/form&gt;
                          &lt;/div&gt;
  </code></pre>
  
  <p>my controller is :</p>
  
  <pre><code> var app = angular.module('loginFormApp', []);
              app.controller('loginFormCtrl', function($scope, $http, AuthService) {
                  $scope.loginCall = function() {
  
                      AuthService.authentication();
  
                  };
              });
  </code></pre>
  
  <p>My Factory Service is :</p>
  
  <pre><code> app.factory('AuthService', function() {
              var factory = {};
              factory.authentication = function($http) {
                  //alert("hello1");
                  $http.post("http://103.19.89.152:8080/ccp-services/authenticate", {
                          'userName': $scope.loginId,
                          'password': $scope.password
                      })
                      .then(function(response) {
  
                          window.location.href = "http://103.19.89.152:8080/earnfit/ui/angular/dashboard.html";
                      });
              };
              return factory;
          });
  </code></pre>