nishil bhave
nishil bhave

Reputation: 632

(IONIC) Error: [$injector:unpr] Unknown provider: dataServicesProvider <- dataServices <- AuthCtrl

Im not able to connect to a custom service (dataService) which i had made. here is the controller code

angular.module('auth.controller', [])
.controller('AuthCtrl',function($scope, $state, $ionicHistory, dataService) {
//some code 
});

here is my custom service

angular.module('data.service',[])
    .service('dataService', ['$http',function ($http) {
//some code
}])

my main controller

angular.module('wgmsApp.controllers', ['auth.controller','dashboard.controller')
.controller('MenuCtrl', function($scope, $ionicPopup, $state){
    }])

my service.js

angular.module('wgmsApp.services', ['data.service'])

All files are included properly in index.html

Upvotes: 1

Views: 364

Answers (2)

Ahmad Baktash Hayeri
Ahmad Baktash Hayeri

Reputation: 5880

You have defined the service dataService as part of the module data.service.

Therefore, to be able to leverage the services of one particular module in another, you'll need to inject the former into the latter.

i.e.

angular.module('auth.controller', ['data.service']) // inject the `data.service` module here
   .controller('AuthCtrl',function($scope, $state, $ionicHistory, dataService) {
   //some code 
});

Upvotes: 1

Shailendra Singh Deol
Shailendra Singh Deol

Reputation: 637

try to use like this-

   angular.module('auth.controller', [])
    .controller('AuthCtrl',["$scope","$state","$ionicHistory","dataService",function($scope, $state, $ionicHistory, dataService) {
    //some code 
    }]);

Hope this may help you.

Upvotes: 0

Related Questions