My app was working fine, I installed cordova geolocation, but after adding $cordovaGeolocation and $ionicPopup nothing is working, I redid the code a few times and checked and rechecked the spelling, etc.
Here is my error:
Uncaught Error: [$injector:modulerr] Failed to instantiate module caffeinehit due to: Error: [$injector:modulerr] Failed to instantiate module caffeinehit.services due to: Error: [$injector:nomod] Module 'caffeinehit.services' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument.
Top code from app.js:
var app = angular.module('caffeinehit', [
'ionic',
'ngCordova',
'caffeinehit.controllers',
'caffeinehit.services',
'caffeinehit.filters'
]);
services.js Code:
var app = angular.module('caffeinehit.services', []);
app.service("YelpService", function ($q, $http, $cordovaGeolocation, $ionicPopup) {
var self;
self = {
'page': 1,
'isLoading': false,
'hasMore': true,
'results': [],
'lat': 51.545540,
'lon': -0.0223374,
'load': function () {
self.isLoading = true;
var deferred = $q.defer();
ionic.Platform.ready(function () {
$cordovaGeolocation
.getCurrentPosition({timeout: 10000, enableHighAccuracy: false})
.then(function (position) {
self.lat = position.coords.latitude;
self.lon = position.coords.longitude;
Later having trouble with adding $ionicPopup:
}, function (err) {
console.error("Error getting position");
console.error(err);
$ionicPopup.alert({
'title': 'Please switch on your gps',
'template': "It seems like you switch off your gps, please turn it on"
});