Reputation: 2210
I have this error and I dont know why
var app = angular.module('starter', ['ionic', 'starter.controllers', 'ngCordova'])
.run(function($ionicPlatform, $cordovaSQLite, $rootScope, AppStart) {
$ionicPlatform.ready(function() {
if(window.cordova && window.cordova.plugins.Keyboard) {
cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
}
if(window.StatusBar) {
StatusBar.styleDefault();
}
$cordovaSQLite.deleteDB("my.db");
db = $cordovaSQLite.openDB("my.db");
$cordovaSQLite.execute(db, "CREATE TABLE IF NOT EXISTS preferences (id integer primary key, description string, value string)");
AppStart.init();
});
})
.factory("AppStart", function($scope, $cordovaSQLite) {
var query = "SELECT id, description, value FROM preferences";
return {
init: function() {
var res = "hello";
}
}
})
When run my code, i get an error ror: [$injector:unpr] Unknown provider: $scopeProvider <- $scope <- AppStart
Why do i get an unknown provider even though i hv set it.
Upvotes: 0
Views: 1275
Reputation: 2078
You shouldn't be injecting $scope
in a factory (service). The way to go would be to change the $scope
inside a controller or directive and if you want to use some variable from your factory with your $scope
, just use $watch
to detect changes in a service variable.
Short version: remove $scope
from the 'AppStart' factory
Upvotes: 1