Good Day,
i am new to angularjs and started playing around mostly on the pulling of data trough web service.
my web service returns a list of latitude and longitude from my database
here is the code
[WebMethod]
public List<friendlyforces> get_friendly(string regionid , string type)
{
List<friendlyforces> friendlies = new List<friendlyforces>();
List<SqlParameter> parameters = new List<SqlParameter>();
parameters.Add(new SqlParameter("@regid", regionid));
parameters.Add(new SqlParameter("@type", type));
SqlDataReader readers = SqlHelper.ExecuteReader(connection, "friendlyforces", parameters.ToArray());
while (readers.Read())
{
friendlies.Add(new friendlyforces());
friendlies[(friendlies.Count - 1)].unit_name = readers["unit_name"].ToString();
friendlies[(friendlies.Count - 1)].address = readers["adrress"].ToString();
friendlies[(friendlies.Count - 1)].latitude = readers["latitude"].ToString();
friendlies[(friendlies.Count - 1)].longitude = readers["longitude"].ToString();
friendlies[(friendlies.Count - 1)].icon = readers["icon"].ToString();
}
return friendlies;
}
now on my angularjs enabled page i am trying to display the data given by the web service here is the code
var app = angular.module('Services', []);
app.controller('latController', function ($scope, $http) {
var url = "Services/datapull.asmx/get_friendly";
$http({
method: 'POST',
url: url,
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
data: JSON.stringify({ regionid: "7", type: "pnp" })
}).success(function (data) {
var myjson = JSON.parse(data);
$scope.locations = JSON.parse(myjson);
});
})
now when the web service is invoked it returns an error stating that i am missing a parameter the regionid i tried $.param : ({regionid : "7" , type : "pnp" }) and
param : JSON.stringify ({regionid : "7" , type : "pnp"})
but it retruns the same error parameter is missing
any suggestions?
thank you