I am calling a web API with angularJS Service.
My webp API method is working fine without parameters '/api/Subpart/'
When i tried to pass parameters , Web API method is not firing.
Angular service
.service('subpartService', ['$http', function ($http) {
this.getSubparts = function (val) {
return $http.get('/api/Subpart/'+val); // With parameters not working
};
}])
Web API Controller Action
[Route("api/Subpart/{strsubpart}")]
public List<tbl_Employee> GetSubparts(string strsubpart)
{
Entities db = new Entities();
var data = db.tbl_Regulation.Where(c => c.Subsection == "ABC");
return data.ToList();
}
I have the solution.It has pass parameters with ?
this.getSubparts = function (val) {
var subUrl = "http://localhost/api/Subpart/sub_part?subpart="+ val;
return $http.get(subUrl);
};