无法确定为何不提交表单

时间:2013-08-09 00:39:33

标签: angularjs

我创建了一个基本的角度形式,无法确定它没有提交的原因。

http://contact-info.checkoutbiblebowl.com/

表单验证有效且仍无法提交。我觉得我忽略了一些愚蠢的东西,但是在最近几天看了这个并且无法弄清楚它是什么。有什么建议吗?

<form method='post' action='' name='form' novalidate ng-controller="myController">
    <div class="row form">
        <div class="form-inline">
        <div class="form-row">
            <label class="form-label" style='margin-top: 20px'>Name</label>
            <div class="form-item">
                <div style="float: left">
                    First<br/>
                    <input type="text" ng-model="firstName" name="firstName" class="small" style="width: 200px" maxlength="32" required>
                    <div ng-cloak ng-show="form.firstName.$error.required" class="required">First name is required</div>
                </div>
                <div style="float: left; margin-left: 1em">
                    Last<br/>
                    <input type="text" ng-model="lastName" name="lastName" class="small" style="width: 200px" maxlength="32" required>
                    <div ng-cloak ng-show="form.lastName.$error.required" class="required">Last name is required</div>
                </div>
                <div style="clear:both"></div>
            </div>
        </div>
        <div class="button-row">
            <button ng-disabled="!form.$valid" type="submit" class="btn" ng-click="debug()">Submit</button>
        </div>
    </div>
    </div>
</form>

我的控制器:

<script type="text/javascript">
    angular.module('contact', []).
    controller('myController', function ($scope) {
        $scope.debug = function () {
            console.log($scope.form);
        }
    });
</script>

1 个答案:

答案 0 :(得分:3)

我认为您只需要明确指定操作,而不是使用空字符串,否则angular将阻止提交。

http://docs.angularjs.org/api/ng.directive:form

像这样: http://plnkr.co/edit/WtP03BFVyEsnOqf3n8a4?p=preview