ng提交不在modal内部工作?

时间:2015-04-09 16:43:41

标签: javascript angularjs twitter-bootstrap bootstrap-modal

似乎我的提交按钮没有激活ng-click angular指令,我无法弄清楚原因。似乎每个有这个问题的人都没有在他们的表单中包含他们的提交按钮,我99%肯定我这样做了。

<div class="modal fade" id="subModal" ng-controller="SubscriberController" ng-controller-as="subCtrl">
    <div class="modal-dialog modal-md">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times; </span><span class="sr-only">Close</span></button>
                <h2 class="modal-title">Subscribe</h2>
            </div>
            <div class="modal-body">
                <div class="row">
                    <div class="col-sm-12">
                        <div class="well">
                            <form ng-submit="console.log('submit')">
                                <div class="form-group">
                                    <label for="subscriber-name" class="control-label"><strong>Name:</strong></label>
                                    <input type="text" class="form-control" ng-model="subCtrl.subData.name" placeholder="John Doe" required>
                                </div>
                                <div class="form-group">
                                    <label for="subscriber-email" class="control-label"><strong>Email:</strong></label>
                                    <input type="email" class="form-control" ng-model="subCtrl.subData.email" placeholder="johndoe@example.com" required>
                                </div>
                                <div class="form-group">
                                    <button type="submit" class="btn btn-success btn-lg btn-block"><i class='fa fa-envelope'></i> Subscribe</button>
                                </div>
                                <div re-captcha ng-model="subCtrl.subData.captcha"></div>
                            </form>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

1 个答案:

答案 0 :(得分:0)

您需要输入类似

的内容
<input ng-model="myForm.email" type="email" class="form-control" id="subCtrl.subData.email" placeholder="johndoe@example.com" required> 

<input ng-model="myForm.name" type="text" class="form-control" ng-model="subCtrl.subData.name" placeholder="John Doe" required> 

进入您的输入,并为您的表单提供名称属性

<form name="myForm" ng-submit="submit()">

plnkr:http://plnkr.co/edit/KRmZkPS6t4ANmAHwTevQ