I have encountered similar questions in the past, but they often involve missing injections, and I hope that is not the issue in my case.
For my current app project, I am attempting to send a GET request to the server to retrieve a list of modules.
Controller
app.controller('ModulesCtrl', ['$scope','modFact','quizIndexFactory', '$http', function($scope, $http, quizIndexFactory, modFact){
$scope.moduleSet;
$scope.status;
getModules();
function getModules(){
modFact.getList()
.then(function (response) {
$scope.moduleSet = response.data;
}, function (error) {
$scope.status = 'unable to load modules in controller: ' + error.message;
});
}
Factory
app.factory('modFact', ['$http', function($http){
var modFact = {};
modFact.getList = function() {
console.log("success");
return $http.get('http://localhost:3000/module');
};
return modFact;
}]);
However, I am encountering an error message specifically pointing to the function call in the controller:
Error: modFact.getList is not a function
Any suggestions? I am following the structure outlined in this blog post: