这一个是我的服务:POST HTTP://本地主机:53178/API/LocationSearchApi 404(未找到)
latModule.service('latLocationSvc',
["$http", "$resource",
function ($http, $resource) {
this.post = function (params) {
var request = $http({
method: "post",
url: "/api/LocationSearchApi",
data: params
});
return request;
};
}]);
这一个是我的控制器:
$scope.searchFilterData = function() {
var params = {
SponsorIcaCid: 88150,
OwnerIcaCid: null,
Cid: null,
TerminalId: null,
RtnCode: null,
LocationName: null,
LocationTypeCode: null,
OwnerName: null,
CountryCode: null,
Address: null,
City: null,
StateProv: null,
Postal: null,
FromLastUpdateDate: null,
ToLastUpdateDate: null,
ErrorCode: null,
ViewFilterType: 5,
IsExportRequest: null,
ExportLocations: null,
MerchantName: null,
MerchantCategory: null,
MccCode: null,
DataProviderType: null,
DataProviderId: null,
PhoneNumber: null,
OptedOut: null
};
var promisePost = latLocationSvc.post(params);
promisePost.then(function(response) {
$scope.locationDtlsList = response;
},function(){});
};
在呼吁这个帖子API我收到以下错误。
POST http://localhost:53178/api/LocationSearchApi 404 (Not Found)
我需要做什么来克服这个错误?当我通过使用$ resource实现服务来调用API时,它可以工作,但在呼叫完成之前,它会在数据到达之后触发事件。由于这个原因,我无法将数据绑定到我的视图。所以我正试图实现这一点。
你可以使用$ timeout [link](https://docs.angularjs。组织/ API/NG /服务/ $超时) –