0

I have a form as follows:

<form name="ratiosReport" 
      novalidate 
      ng-submit="ratiosReport.$valid" 
      action="reports/ratios?fromDate={{vm.fromDate}}" 
      method="get">

If the fromDate hasn't been filled in, I'd like the form not to submit. How do I do this, is it possible?

Most use-cases are where the form doesn't have an action, and the ng-submit calls a method in the controller. Like this answer, from which I took the ng-submit attribute, but it only works if calling a method, not preventing the GET submit to the ACTION attribute.

Community
  • 1
  • 1
Sean
  • 14,359
  • 13
  • 74
  • 124

1 Answers1

0

According to this page, ng-submit only prevents default actions, i.e. posting to itself. So it's not an option. Looks like I need to remove the action attribute and build the url manually in a method in the controller, called by ng-submit (and effectively use window.location.href = xxx).

Sean
  • 14,359
  • 13
  • 74
  • 124