错误:[ng:areq]

时间:2016-11-22 00:12:32

标签: javascript angularjs

当我点击网址时,我收到一条错误消息: 我从html路由到正确的js文件仍然我收到以下错误。请检查代码,问题应该是什么? angular.js:13642错误:[ng:areq] http://errors.angularjs.org/1.5.6/ng/areq?p0=loginController&p1=not%20aNaNunction%2C%20got%20undefined



var app = angular.module('app', []);
app.controller('loginController', function($scope, $http, $window) {
  $scope.username = "";
  $scope.password = "";
  console.log(1);
  $scope.adminLogin = function() {
    $http({
      method: 'POST',
      url: '/login',
      data: {
        "user_name": $scope.username,
        "password": $scope.password
      }

    }).success(function(response) {
      console.log(JSON.stringify(response));

      if (response.status === "true") {
        alert(response.status);
        if (response.store_id != "n.a.") {
          $window.localStorage.store_id = response.store_id;
          console.log("store id: ", $window.localStorage.store_id);
          console.log("store id: ", $window.localStorage.store_id);
          console.log("window.location = '/PricePredictionUI/#/DASHBOARD'");
        }
      } else {
        console.log("window.location = '/PricePredictionUI/#/LOGIN'");
        alert("Login Failed, Please Register or try again...!!");
      }
    }).error(function(error) {
      alert(JSON.stringify(error));
      console.log("window.location = '/error'");
    });
  };
});

<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>

<body ng-app="app" ng-controller="loginController">
  <div class="container" id="login">
    <div class="row">
      <div class="col-md-4 col-md-offset-4">
        <div class="login-panel panel panel-default">
          <div class="panel-heading">
            <h3 class="panel-title">Please Sign In</h3>
          </div>
          <div class="panel-body">
            <form role="form">
              <fieldset>
                <div class="form-group">
                  <input class="form-control" ng-model="username" placeholder="Username" name="username" type="usename" autofocus>
                </div>
                <div class="form-group">
                  <input class="form-control" ng-model="password" placeholder="Password" name="password" type="password" value="">
                </div>
                <div class="checkbox">
                  <label>
                    <input name="remember" type="checkbox" value="Remember Me">Remember Me
                  </label>
                </div>
                <button type="button" class="btn btn-lg btn-success btn-block" ng-click="adminLogin()">Login</button>
              </fieldset>
            </form>
          </div>
        </div>
      </div>
    </div>
  </div>
&#13;
&#13;
&#13;

0 个答案:

没有答案