After a year of working with rails, I decided to tackle my first angular app. While I've been learning from tutorials, I'm facing some challenges now. Despite searching through various SO questions, I couldn't find a solution for this particular issue.
Upon loading the page, I encountered the following error related to module requirements and dependency injection. Any insights on resolving this would be highly appreciated!
Error: [$injector:unpr] Unknown provider: ReleaseProvider <- Release
This is how I set up my main app - mighty.js:
var mightyReal = angular.module('mightyReal', ['ngResource']);
mightyReal.factory ('Release', ['Resource', function($resource) {
return $resource('/api/releases/all');
}]);
For my controller - releaseController.js:
angular.module('mightyReal').controller('releaseController', [ '$scope', 'Release', function($scope, Release){
$scope.releases = Release.query();
}]);
The order in which I loaded js scripts - index.erb:
<script src="js/angular.js"></script>
<script src="js/resource.js"></script>
<script src="js/mighty.js"></script> <!-- main app -->
<script src="js/auth.js"></script>
<script src="js/releaseController.js"></script>
Lastly, here's my sinatra API route - index.rb
get '/api/releases/all' do
content_type :json
Release.all.to_json
end