If you want to submit Form data to different URLs based on selection of select box, You have to do some lengthy code in jQuery or Javascript. But it is very easy build this logic using AngularJS.

Markup

<form action="{{action}}" ng-submit="alertAction($event)">
  <select ng-model="action">
    <option value="action1">Action 1</option>
    <option value="action2">Action 2</option>
    <option value="action3">Action 3</option>
  </select>
  <h4>Action attribute value</h4>
  <div ng-bind="action"></div><br/>
  <button>Submit</button>
</form>

Script

$scope.action = 'action2';
$scope.alertAction = function($event) {
    alert($scope.action);
    $event.preventDefault();
};

0 comments:

Blogroll

Follow this blog by Email

Popular Posts