1

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" />
  <br><br>
  <input type="submit" value="Save" />
</form>

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?

2
  • What's wrong with ngSubmit? Commented Jun 25, 2016 at 17:16
  • I am not getting where to write code and how to call server api and send data. Commented Jun 25, 2016 at 17:32

1 Answer 1

1

html

<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>
      <div class="form-group">
        <label for="exampleInputPassword1">Password</label>
        <input type="password" placeholder="Password" id="exampleInputPassword1" class="form-control" ng-model="user.pass" required>
      </div>
      <button class="btn btn-default" type="submit" ng-click="login(user)" ng-disabled="form1.$invalid">Submit</button>
      <p>{{msgtxt}}</p>
</form>

Controller.js

'use strict';

app.controller('loginCtrl', ['$scope','loginService', function ($scope,loginService) {
    $scope.msgtxt='';
    $scope.login=function(data){
        alert(JSON.stringify(user));
    };
}]);
Sign up to request clarification or add additional context in comments.

2 Comments

I am trying to make http service call in plnkr.co/edit/VJKrDRMJY3Q73bsCgVwX?p=preview. Please let me know to send data(prepareAutoQuoteDTO) to server
please see this plunker and let me know where and how to write that code.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.