For testing purposes, I am trying to make changes to my service calls in Angular. In the sample below, the commented out code works correctly but the uncommented code returns a TypeError: Cannot read property 'success' of undefined.
app.service("waiverService", [
"$http", function ($http) {
var _this = this;
this.get = function (param1, param2) {
//return $http({
// method: "GET",
// url: "api/GetInfo/Get/" + param1 + "/" + param2
//})
// .success(function (data) {
// _this.result = data;
// return data;
// })
// .error(function () {
// return "Error";
// })
//;
return $http.get("api/GetInfo/Get/" + param1 + "/" + param2)
.success(function (data) {
_this.result = data;
return data;
})
.error(function() {
return "Error";
});
};
}]);
What am I missing that causes this error?
Aucun commentaire:
Enregistrer un commentaire