1

My goal is to create an http post method in the service that gets the following parameters from the controller: id, firstname,lastname,email,phonenumber ,in the controller:

function updateClient(client){
    var clientId=client.id;
    var firstName=$("#clientFirstName");
    var lastName=$("#clientLastName");
    var email=$("#clientEmail");
    var phoneNumber=$("#clientPhoneNumber");
    updateClient.postClient().then(function(data) {

    });
}

and in the service:

  testProjectApp.factory('updateClient', function($http, $q) {
   return { ...
1
  • You need to add the service to the list of dependencies in the controller, and then pass the parameters by calling to the function in that service Commented Nov 10, 2015 at 13:43

1 Answer 1

1

You need to define the function in the object you are returning:

testProjectApp.factory('updateClient', function($http, $q) {
   return { 
       postClient : function(firstName, lastName) {
           //do stuff
       }
   }
});
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.