[$injector:modulerr] Failed to instantiate module app due to: Error: [$injector:unpr] Unknown provider: $stateProvider


#1

[$injector:modulerr] Failed to instantiate module app due to:
Error: [$injector:unpr] Unknown provider: $stateProvider

I’m getting this error continue. Dont’ know how to solve it. :frowning:
tried few ways to fix it after goolging and check here. but no good luck yet.
please help!!!

I have 11 controllers according to 11 view html files and 2 services.
I seperate them in each view directory. now each view directory have one html, css and js file for the each view.
I also separated config things too.
following is js file in one of my view directory.

angular.module(‘app’, [])
.config([’$stateProvider’, function ($stateProvider) {
$stateProvider
.state(‘app’, {
url: ‘/events/:eventId’,
views: {
menuContent: {
templateUrl: ‘view/event/event.html’,
controller: ‘EventCtrl’,
},
},
});
}]);

angular.module(‘app.controllers’, [])
.controller(‘EventCtrl’, function ($scope, $stateParams, Events) {
$scope.eventId = $stateParams.eventId;
Events.list(‘123’, function (events) {
Events.getEvent($stateParams.eventId, function (event) {
$scope.event = event;
});
});
});

in my app.js
angular.module(‘app’,
[‘ionic’, ‘ngCordova’, ‘app.controllers’, ‘app.services’, ‘ui.router’]);

angular.module(‘app’)
.constant(‘ApiEndpoint’, {
url: ‘http://localhost:8100/api’,
})
.
.
.

.config(function ($urlRouterProvider) {
// if none of the states in each controller file are matched, use this as the fallback
// $urlRouterProvider.otherwise(’/app/events’);
$urlRouterProvider.otherwise(’/app/login’);
});


#2

Error: [$injector:unpr] Unknown provider: $stateProvider ==== i think you didn’t inject the $stateProvider or there’s something wrong with $stateProvider…


#3

we don’t need to inject $stateProvider since its supported by Ionic, do we?


#4

it should be injected inside config… may I look at your code??