I've encountered an error in my code that reads:
TypeError: undefined is not a function
. It seems to be related to my understanding of promises. I would really appreciate any insights or explanations on this issue.
getProgramDetails: function (program) {
var _this = this;
this.getDetails(program).then(function() {
....
});
},
getDetails: function (program) {
var _this = this;
var deferred = $q.defer();
// The error is triggered at this line
this.http.get({id: program.programID}).then(function(results) {
if (results && results.programID) {
_this.isNewProgram = false;
_this.selectedProgram = {
...
};
} else {
_this.isNewProgram = true;
_this.selectedProgram = {
...
};
}
deferred.resolve();
});
return deferred.promise;
},
http: $resource(
$window.detailsEndpoint',
{ id: '@id' },
{ //parameters default
update: {
method: 'PUT',
params: {}
},
get: {
method: 'GET',
params: {
id: '@id'
}
},
post: {
method: 'POST'
}
})