I'm building an app in AngularJS and Ionic, using DreamFactory for my backend. I'm trying to create a controller and a service to obtain data from DreamFactory. The error I'm seeing is:
Error: [$injector:unpr] Unknown provider: ScheduleServiceProvider <- ScheduleService <- ScheduleCtrl
Here's my controller:
(function() {
'use strict';
angular.module('rota').controller('ScheduleCtrl', ['ScheduleService',
'DreamFactory', function(ScheduleService, DreamFactory) {
// Params for call
scope.callParams = {
table_name: 'Schedule',
params: {
limit: 20
}
}
// Function to call custom service
$scope.getRecords = function() {
ScheduleService.getSchedule(callParams).then(
function(result){console.log(result.data.record)},
function(reject){console.log("request failed")}
);
}
}
])
})();
And here's my service:
(function() {
'use strict';
angular.module('rota').factory('ScheduleService', ['DreamFactory',
function(DreamFactory) {
return {
getSchedule: function(tableNameStr) {
// Create request obj
var request = {
table_name: tableNameStr
};
return DreamFactory.api.sql.getRecords(request);
}
};
}])
});
Adding this answer to close this question.
Seems like the enclosing function is not executed. Parentheses are missing at the end of the function.
Check your index.html file, i think you have not added your ScheduleService file.