I have a problem it is api structure such that i have post form data same as per the api given
{"data":
{"type":"Open",
"ownership_type":"Agent",
"price":300,
"price_type":"Daily",
"area":40,
"area_unit":"Sq Ft",
"full_address":
{"address":"asasasasasa",
"city":"As",
"state":"saasa",
"zip_code":177820,
"google_location":"sdsdsdsdsd"
},
"description":"sdsdsdsdsdsdsdsds",
"other_features":
["Audience","Display Units","Furninshing"],
"contact_details":
{"name":"Ashsish Ranot",
"email":"asasasasas@asasa.com",
"phone":7878278137
},
"type_of_advertisement":
["ATM","Banner/Poster","Stalls"]
}
}
- i have using MEAN stack.
- i have writing my application on angularjs
var app = angular.module('mypropertysubmit', []);
app.controller('submitCtrl', function ($scope, $http) {
$scope.submit_form = function()
{
$http({
url: "http://localhost:3008/api/submit-property",
method: "POST",
headers: {'Content-Type': 'application/x-www-form-urlencoded'},
data: $.param($scope.Property)
}).success(function(data, status, headers, config) {
$scope.status = status;
}).error(function(data, status, headers, config) {
$scope.status = status;
});
}
});
and my jade code is
div(ng-app='mypropertysubmit', ng-controller='submitCtrl')
form
select(ng-model='Property.type')
option(value='Open') Open
option(value='Closed') Closed
select(ng-model='Property.ownership_type')
option(value='Sole Owner') Sole Owner
option(value='Partnership') Partnership
option(value='Agent') Agent
input(type='number', value='0', name='price', ng-model='Property.price')
select(ng-model='Property.price_type')
option(value='Daily') Daily
option(value='Weekly') Weekly
input(type='number', value='0', name='Area', ng-model='Property.area')
select(ng-model='Property.area_unit')
option(value='Daily') Sq Ft.
option(value='Weekly') Sq m.
input(type='text', name='Address', ng-model='Property.contact_details.address')
input(type='text', name='City', ng-model='Property.contact_details.city')
input(type='text', name='state', ng-model='Property.contact_details.state')
input(type='number', value='000000', name='zipcode', ng-model='Property.contact_details.zipcode')
input(type='text', value='000000', name='googlelocation', ng-model='Property.contact_details.googlelocation')
input(type='textbox', name='description', ng-model='Property.description')
input(type='checkbox', value='Audience', ng-model='Property.other_features.audience')
input(type='checkbox', value='Display Units', ng-model='Property.other_features.du')
input(type='checkbox', value='Sound Units', ng-model='Property.other_features.su')
input(type='checkbox', value='Furnishing', ng-model='Property.other_features.f')
input(type='checkbox', value='Air Conditioning', ng-model='Property.other_features.ac')
input(type='text', name='name', ng-model='Property.contact_details.name')
input(type='email', name='email', ng-model='Property.contact_details.email')
input(type='phone', name='phone', ng-model='Property.contact_details.phone')
input(type='checkbox', value='ATM', ng-model='Property.type_of_advertisement.atm')
input(type='checkbox', value='Mobile/Communication Tower', ng-model='Property.type_of_advertisement.mct')
input(type='checkbox', value='Banner/Poster', ng-model='Property.type_of_advertisemen.bpt')
input(type='checkbox', value='Hoarding Board', ng-model='Property.type_of_advertisement.hb')
input(type='checkbox', value='Stalls', ng-model='Property.type_of_advertisement.st')
input(type='checkbox', value='Digital Offine Advertising', ng-model='Property.type_of_advertisement.doa')
input(type='checkbox', value='Area for Display', ng-model='Property.type_of_advertisement.afd')
input(type='submit', ng-click='submit_form()' value='Submit')
but i get api structure like this
{"status":"success","data":[{"_id":"58e0d5566ce6fd2af4cc4670","__v":0,"date_add":"2017-04-02T10:41:26.344Z","type_of_advertisement":[],"other_features":[]},{"_id":"58e0d5576ce6fd2af4cc4671","__v":0,"date_add":"2017-04-02T10:41:27.191Z","type_of_advertisement":[],"other_features":[]},{"_id":"58e0d5576ce6fd2af4cc4672","__v":0,"date_add":"2017-04-02T10:41:27.291Z","type_of_advertisement":[],"other_features":[]},{"_id":"58e0d5576ce6fd2af4cc4673","__v":0,"date_add":"2017-04-02T10:41:27.529Z","type_of_advertisement":[],"other_features":[]},{"_id":"58e0d5576ce6fd2af4cc4674","__v":0,"date_add":"2017-04-02T10:41:27.638Z","type_of_advertisement":[],"other_features":[]},{"_id":"58e0d5576ce6fd2af4cc4675","__v":0,"date_add":"2017-04-02T10:41:27.904Z","type_of_advertisement":[],"other_features":[]},{"_id":"58e0d5586ce6fd2af4cc4676","__v":0,"date_add":"2017-04-02T10:41:28.106Z","type_of_advertisement":[],"other_features":[]},{"_id":"58e0d5a66ce6fd2af4cc4677","__v":0,"date_add":"2017-04-02T10:42:46.718Z","type_of_advertisement":[],"other_features":[]},{"_id":"58e0d5a66ce6fd2af4cc4678","__v":0,"date_add":"2017-04-02T10:42:46.992Z","type_of_advertisement":[],"other_features":[]},{"_id":"58e0d5a76ce6fd2af4cc4679","__v":0,"date_add":"2017-04-02T10:42:47.157Z","type_of_advertisement":[],"other_features":[]},{"_id":"58e0d5a76ce6fd2af4cc467a","__v":0,"date_add":"2017-04-02T10:42:47.179Z","type_of_advertisement":[],"other_features":[]},{"_id":"58e0d5a76ce6fd2af4cc467b","__v":0,"date_add":"2017-04-02T10:42:47.713Z","type_of_advertisement":[],"other_features":[]},{"_id":"58e0d5a76ce6fd2af4cc467c","__v":0,"date_add":"2017-04-02T10:42:47.818Z","type_of_advertisement":[],"other_features":[]},{"_id":"58e0d5a86ce6fd2af4cc467d","__v":0,"date_add":"2017-04-02T10:42:48.115Z","type_of_advertisement":[],"other_features":[]},{"_id":"58e0d5a86ce6fd2af4cc467e","__v":0,"date_add":"2017-04-02T10:42:48.224Z","type_of_advertisement":[],"other_features":[]},{"_id":"58e0d5a86ce6fd2af4cc467f","__v":0,"date_add":"2017-04-02T10:42:48.572Z","type_of_advertisement":[],"other_features":[]},
please help me to post the form data as per the apis given