Currently a simple app that contains a controller and a service. It looks like the service loads correctly into the module but the controller isn't picking it up. If I remove the 'Photo' injection from the controller, the code doesn't crash. It's only when I try to inject the service into the controller that I see a problem.
controllers.js file:
var photoViewer= angular.module('photoViewer', ['photoViewer.services']);
photoViewer.controller('PhotoListCtrl', ['$scope', 'Photo', function($scope, Photo) {
$scope.photos = Photo.getPhotos();
}]);
services.js file:
angular.module('photoViewer.services', [], function($provide) {
$provide.factory('Photo', ['$resource', function($resource){
return {
getPhotos: function() {
return [
{'name': 'test1'},
{'name': 'test2'}
];
}
}
}]);
});
Html file:
<html ng-app="photoViewer">
<head>
<title>Photo Viewer</title>
</head>
<body>
<div ng-controller="PhotoListCtrl" style="width:500px;">
<div>{{photos.length}} total photos found.</div>
<ul>
<li ng-repeat="photo in photos">
{{$index + 1}} - {{photo.name}}
</li>
</ul>
</div>
<script src="/js/libs/angular.min.js"></script>
<script src="/js/services.js"></script>
<script src="/js/controllers.js"></script>
</body>
</html>