Cannot submit a form from a controller

Hi, I’m trying to integrate paypal into my ionic app. I’m using appinbrowser (I cannot get to work the paypal plugin).

I’ve created a form with all the necessary data but when I try to submit the form (not directly cause I need to submit it using $window.open) I cannot get it working, I always get the error:

TypeError: $scope.formScope.f1.submit is not a function, so the new window is opened but it always fails to complete the paypal form.

Here is the codepen:

See the Pen pJLBLO by Daniel Lopez Mesa (@danilm) on CodePen.

Thanks

Form submissions in Angular need to use ng-submit, the method .submit() doesn’t exist in the scope you’ve obtained from ng-init. What you can do is obtain the parent element from formScope and using angular.element(formEl).submit() (.submit() is a jQuery Lite method) that will submit the form.

Thanks for your help,

I’ve tried the following
var frm = angular.element(’#f1’);
frm.submit();

Now the form is submitted. But I have another issue (maybe you can help as well). I open a new window and I would like to load the submitted form into that window.

So far, I can only open a blank window and the content is loaded inside the parent instead the child.

Thanks

Try something like the following, adapt to what you currently have.

var w = window.open();
var html = $("#toNewWindow").html();
$(w.document.body).html(html);

You need to assign the new window as a variable and then using jQuery Lite insert the HTML form into the window.

Thanks, please take a look at mi codepen so you can see what I’m trying to do:

You need to do something like the following: externalPaymentWindow.html(formHTML)