I'm struggling with setting up a firebase factory for use in my controllers. Currently, this is how my code appears:
index.html
...
<!-- integrating firebase -->
<script src="lib/firebase/firebase.js"></script>
<script src="lib/angularfire/dist/angularfire.min.js"></script>
<script src="js/app.js"></script>
<script src="js/controllers.js"></script>
<script src="js/routes.js"></script>
<script src="js/services.js"></script>
<script src="js/directives.js"></script>
...
app.js
angular.module('app',
['ionic', 'app.controllers', 'app.routes', 'app.services', 'app.directives'])
.run(function($ionicPlatform) {
$ionicPlatform.ready(function() { ....
services.js
angular.module('app.services', ['firebase'])
.factory('itemsFactory', function($firebaseArray) {
var ItemsRef = new Firebase("https://].firebaseio.com/items");
return $firebaseArray(ItemsRef);
})
.service('BlankService', [function(){
}]);
controllers.js
angular.module('app.controllers')
.controller('itemCtrl', function($scope, itemsFactory) {
$scope.items = itemsFactory;
$scope.saveItem = function(){
$scope.items.$add({
"name": "Frank",
"lastname": "Sinatra"
});
};
});
Despite trying to rearrange the app.servies
before the app.controllers
, the controller still cannot recognize the itemsFactory
. Any insights on what could be going wrong? Appreciate any guidance offered.