node.js中使用angularjs表单无法发出HTTP请求

在一个模态框中使用form表单,总是无法发出HTTP请求(使用的是angularjs中的$http服务),求大佬告知哪里出错
图片描述

图片描述

完整代码,我把jQuery放在angularjs之前引入发现一切功能都正常,就没使用uibootstrap

<!DOCTYPE html>
<html lang="en">
<head>

<meta charset="UTF-8">
<title>Title</title>
<base href="/">

<script src="jquery.min.js"></script>

<script src="angular.min.js"></script>

<link rel="stylesheet" href="bootstrap.min.css">
<script src="bootstrap.min.js"></script>

<script>
    angular.module('myApp',[])
            .controller('myController',['$scope','$http',function($scope,$http){
                $scope.account='';
                $scope.password='';
                $scope.submit=function(){
                    console.log('example');
                    $http.post('api/login',{
                        Account:$scope.account,
                        PassWord:$scope.password
                    }).success(function(data){
                        console.log(data);
                    }).error(function(data){
                        console.log(data);
                    });
                };
            }]);
</script>

</head>
<body ng-app="myApp" ng-controller="myController">

<button type="button" class="btn btn-default" data-toggle="modal" data-target="#loginModal">登陆</button>
<div  class="modal fade" id="loginModal" tabindex="-1" role="dialog" aria-hidden="true" data-backdrop="false">
    <div class="modal-dialog" >
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
            </div>
            <div class="modal-body">
                <form  ng-submit="submit()" novalidate>
                    <div class="form-group">
                        <label for="loginAccount">账号</label>
                        <input type="text"  ng-model="account" class="form-control" id="loginAccount" placeholder="Account">
                    </div>
                    <div class="form-group">
                        <label for="loginPassword">密码</label>
                        <input type="password"  ng-model="password" class="form-control" id="loginPassword" placeholder="Password">
                    </div>
                    <div class="form-group">
                        <button type="submit" data-dismiss="modal" class="btn btn-default">登陆</button>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>

</body>
</html>

阅读 2.6k
2 个回答

看一眼完整的html代码。

谢邀

你的代码不是很完整 看不出来
如果你的打印一个都没出来,我怀疑你的controller并不是modal的控制器

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题