Restangular POST form data in json format in Angular JS

后端 未结 1 1983
栀梦
栀梦 2021-01-04 00:21

I am new to Angular JS and I am in a need to use restangular POST of form data in json format. Also I am new to the POST functionalities, can anyone tell me how I can do it

1条回答
  •  無奈伤痛
    2021-01-04 00:53

    In Restangular posts should be done to collections not elements.

    In your case POST should be made like this;

    $scope.user = {email :"", password: "", confpass: ""};
    

    Then make POST request like;

    Restangular.all('data.json/:user').post("users", $scope.user);
    

    Reference;

    https://github.com/mgonto/restangular#element-methods

    0 讨论(0)
提交回复
热议问题