Angular input 无法获取ng-module

用的是Angular1.6,在form表单的input控件中用ng-module双向绑定书记
form表单代码

<!DOCTYPE html>
<html>


<head>
    <meta charset="utf-8">
    <link rel="stylesheet" type="text/css" href="css/bootstrap/bootstrap.css">
    <script src="js/angular/angular.js"></script>
    <script src="form.js"></script>
</head>

<body ng-app="UserInfoModule">
    <div class="panel panel-primary">
        <div class="panel-heading">
            <div class="panel-title">双向数据绑定</div>
        </div>
        <div class="panel-body">
            <div class="row">
                <div class="col-md-12">
                    <form class="form-horziontal" role="form" ng-controller="userInfoCtrl">
                        <div class="form-group">
                            <label class="col-md-2 control-label">
                            邮箱:
                            </label>
                            <div class="col-md-10">
                                <input type="email" class="form-control" placeholder="123@123.com" ng-module="userInfo.email"/>
                            </div>
                            {{userInfo.email}}
                        </div>
                        <div class="form-group">
                            <label class="col-md-2 control-label">
                            密码:
                            </label>
                            <div class="col-md-10">
                                <input type="password" class="form-control" placeholder="只能是数字,字母,下划线" ng-module="userInfo.password"/>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</body>
</html>

controller代码

var userInfoModule = angular.module('UserInfoModule',[]);
userInfoModule.controller('userInfoCtrl',['$scope',function($scope){
    console.log("Start");

    $scope.userInfo={
        email:"123456@163.com",
        password:"123",
        autoLogin:true
    };
    debugger;
}])

打开页面输入框没值

阅读 2.1k
1 个回答

字段名拼写错误:module指模块,model指模型

HTML结构中的数据模型绑定字段应该为ng-model

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