Javascript expressjs中来自angularjs控制器的未识别对象帖子

Javascript expressjs中来自angularjs控制器的未识别对象帖子,javascript,angularjs,express,Javascript,Angularjs,Express,我有一个项目的登录页面管理员重定向到仪表板。它使用expressjs作为服务器端,angularjs作为客户端 此客户端登录页面使用angularjs //this is the angular controller that use for get the data from login form (function () { 'usestrict'; "the initialize angular module" angular.module(

我有一个项目的登录页面管理员重定向到仪表板。它使用expressjs作为服务器端,angularjs作为客户端

此客户端登录页面使用angularjs

//this is the angular controller that use for get the data from login form
    (function () {
        'usestrict';
    "the initialize angular module"
        angular.module("myAdmin",[]).controller('loginCtrl', function($scope, $http){
            $scope.login = function() {
                var userEmail = $scope.user.email;
                var userPassword = $scope.user.password;

                $http.post('/admin/',{useremail:userEmail, userpassword:userPassword});   
            }   
        })
    })();
这是html的登录页面

<!DOCTYPE html>
<html lang="en" >
  <head>
    <title>Awi Admin</title>
    <meta charset="utf-8">
    <meta name="description" content="Aplikasi AWI Realtime Lelang Menggunakan Framework ExpressJS dan Realtime Database Firebase">
    <meta name="author" content="Muhammad Abubakar Siddiq - MAS Abbe">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
    <link rel='stylesheet' href='/stylesheets/login.css'/>
    <link rel="stylesheet" type="text/css" href="/stylesheets/font-awesome.min.css">>
  </head>
  <body ng-app="myAdmin">
    <div class="container">
      <div class="profile">
          <button class="profile__avatar" id="btn_avatar">
            <img src="/images/avatar.png" alt="Avatar" />
          </button>
        <div class="profile__form">
          <div class="profile__fields">
          <h3 class="text-center">Welcome Admin Lelang</h3>
            <form name="login-form" role="form" ng-controller="loginCtrl" novalidate>
              <div class="fields">
                <input type="text" class="input" placeholder="Username" ng-model="user.email" required/>
                <span style="color:red" ng-show="login-form.email.$dirty && login-form.user.$invalid">
                  <span ng-show="login-form.email.$error.required">Username is required.</span>
                </span>
              </div>
              <div class="fields">
                <input type="password" class="input" required-pattern=.*\S.* placeholder="password" ng-model="user.password"/>
                <span style="color:red" ng-show="login-form.password.$dirty && login-form.user.$invalid">
                  <span ng-show="login-form.password.$error.required">Password is required.</span>
                </span>
              </div>
              <div class="alert alert-warning" ng-show="login-form.email.$error.email">
                <em class="fa fa-lg fa-warning">&nbsp;</em>Peringatan, username atau password salah
              </div>
              <div class="profile__footer">
                <center>
                  <button class="btn" id="btn-submit" ng-click="login()">LOG IN</button>
                </center>
              </div>
            </form>
          </div>
        </div>
      </div>
    </div>
    <script>
      document.getElementById('btn_avatar').addEventListener('click', 
        function () {
          [].map.call(document.querySelectorAll('.profile'),
          function(el) {
            el.classList.toggle('profile--open');
          });
        }
      );
    </script>
    <script type="text/javascript" src = "/javascripts/jquery-1.11.1.min.js"></script>
    <script type="text/javascript" src = "/javascripts/bootstraps/bootstrap.min.js"></script>    
    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.7.2/angular.min.js"></script>
    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.7.2/angular-resource.min.js"></script>
    <script type="text/javascript" src = "/javascripts/login.js"></script>//==> this is the function for login that call the angular controller
  </body>
</html>
这是我在github中的项目

我在这个项目中遇到的问题是,从angular controller的post函数到检测为未识别的expressjs post渲染的数据。 谁能告诉我原因是什么??以及如何解决这个问题。 此函数用于运行firebase auth()函数

$http({
  method: 'POST',
  url: '//admin/',
  data: {useremail:userEmail, userpassword:userPassword}
}).then(function(rsp){...});
   app.post('/admin/', (req, res)=>{
        console.log("####Success");
        console.log('post login '+req.body.useremail, req.body.userpassword);
        admin.auth().signInWithEmailAndPassword(req.body.useremail, req.body.userpassword)
        .then(function (user) {
            res.render('/admin/home');
            console.log("success login admin".user.uid);
        })
        .catch(function(err){
            res.send("fail");
            console.log("Error while executing firebase.auth() ",err);
        });
    });

这是角度控制器

(function () {
    'usestrict';
"the initialize angular module"
    angular.module("myAdmin",[]).controller('loginCtrl', function($scope, $http){
        $scope.login = function() {
            var userEmail = $scope.user.email;
            var userPassword = $scope.user.password;
            var myObject = {useremail:userEmail, userpassword:userPassword}

            $http({
                method: 'POST',
                url   : '/admin/',
                data  : JSON.stringify(myObject)
            });   
        }   
    })
})();
这是expressjs函数

   app.post('/admin/', (req, res)=>{
        console.log("####Success");
        console.log('post login '+req.body.useremail, req.body.userpassword);
        admin.auth().signInWithEmailAndPassword(req.body.useremail, req.body.userpassword)
        .then(function (user) {
            res.render('/admin/home');
            console.log("success login admin".user.uid);
        })
        .catch(function(err){
            res.send("fail");
            console.log("Error while executing firebase.auth() ",err);
        });
    });

远程桌面咨询后,final fixed(最终修复)

我是否需要在express中使用它?不,这应该是AngularJ提供的。仍然存在相同的问题,身份不明:(哦,这很奇怪,你能检查一下控制台上是否有任何错误吗?控制台上显示“可能未处理的拒绝”。但问题是为什么express检测到数据身份不明。你似乎发布了比你的问题合理的更多的代码。你需要自己更好地解决此问题。我们不是调试器。你需要d来隔离问题并从那里进行调试。请阅读并了解如何进行调试,因为提供MCVE有助于用户回答您的问题以及未来用户与您的问题相关。