ngSubmit在模式内部不起作用? [英] ngSubmit not working inside modal?

查看:90
本文介绍了ngSubmit在模式内部不起作用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

似乎我的提交按钮未激活ng-click角度指令,我无法弄清楚原因.似乎其他所有遇到此问题的人都没有在表单中包含他们的提交"按钮,而且我99%的确定自己做到了.

It seems that my submit button is not activating the ng-click angular directive and I cannot figure out why. It seems that every other person that had this problem didn't include their submit button inside of their form, and I'm 99% sure I did that.

<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>

推荐答案

您需要输入

<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> 

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

into your inputs, and give your form a name attribute

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

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

这篇关于ngSubmit在模式内部不起作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆