Angular 在第一个表单之后提交第二个表单 validation/promise

Angular to submit second form after first form validation/promise

我在 Angular 中提交一个带有 update() 函数的表单,然后验证,returns 一个承诺,如果成功,然后提交第二个表单。

问题是,第二个表单不会使用 document.getElementById(elementID).submit(); 提交;方法。但是,它将提交 document.getElementById(elementID).click();但当然仅限于非触摸设备。

底线 - 为什么 submit() 不起作用?

这是一个简化版的 jsFiddle:http://jsfiddle.net/jimcamut/xos805gk/

这是我处理表单提交的完整版本的函数。

$scope.update = function(user) {

        if ($scope.earlyUser.$valid) {
            $scope.master = angular.copy(user);

            console.log("Form submitted on front end");


            // This integrates ParseJS and submits the data to a database - all good here, except after the promise
            var parseUser = new Parse.Object("LaunchUser");
            parseUser.setACL(new Parse.ACL());
            parseUser.save({
                name: $scope.master.name,
                email: $scope.master.email,
                zipcode: $scope.master.zipcode
            },{
                error: function(model, error) {
                    console.log("error is...");
                    console.log(error);
                }

            // Returns a promise
            }).then(function(object) {


                // Problem area here when attempting to submit second form...
                document.getElementById('mc-embedded-subscribe').submit();



                $scope.reset();
            });

        } else {
            alert("Please correct the red form fields.");
        }
    };

id='mc-embedded-subscribe' 的元素是一个输入,但您需要 "submit()" 一个表单。 这条线

document.getElementById('mc-embedded-subscribe').submit();

应该更改为

document.getElementById('mc-embedded-subscribe-form').submit();

这里有一个新的 fiddle 进行了此更改,并且有效! http://jsfiddle.net/kx8dn8wc/