- 5 months ago 15
Javascript Question

Angular js form submit and send prepared json data to server

I want to prepare data on the form submit event and send it to the server.

I have an form in step1.php file

<form name="DTOstep1" >
<input type="text" name="save_quote_email" id="save_quote_email" />
<input type="submit" value="Save" />

When I submit this form, I want to call Controller function from app/ctrl/autoQuoteCtrl.js

Please let me know how to make an api call here to send data(O) to the server?



<form role="form" name="form1">
      <div class="form-group">
        <p>Welcome : <span>{{user.mail}}</span></p>
        <label for="exampleInputEmail1">Mail</label>
        <input type="text" placeholder="Enter name"  class="form-control" ng-model="user.mail" required>
      <div class="form-group">
        <label for="exampleInputPassword1">Password</label>
        <input type="password" placeholder="Password" id="exampleInputPassword1" class="form-control" ng-model="user.pass" required>
      <button class="btn btn-default" type="submit" ng-click="login(user)" ng-disabled="form1.$invalid">Submit</button>


'use strict';

app.controller('loginCtrl', ['$scope','loginService', function ($scope,loginService) {