【发布时间】:2017-05-13 18:38:30
【问题描述】:
使用 angularjs 向 Web api 发出获取请求时出现错误。可以对此发表任何评论。
$scope.getSelections = function () {
var user = ($scope.userInfo.userName).toString();
selectionsaveSrv.getSelections(user).then(function (data) {
var data = data;
});
}
服务:
function selectionsaveservice(appConfig, $q, fSrv, localStorageService, adalAuthenticationService, $http) {
getSelections = function (user) {
var user = user;
var webApiuri = appConfig.webApiUri + '/UserPreferences/GetSelections';
$http.get(webApiuri, { params: { UserName: user } }).
success(function (data, status, headers, config) {
return data;
}).
error(function (data, status, headers, config) {
});
}
return { getSelections: getSelections }
}
【问题讨论】:
-
我认为
$http服务的success和error方法在1.2.x 版本中已从角度中删除。用then方法替换那些。