Angularjs - Error: [$injector:unpr]


I'm trying to to use the Angular UI Bootstrap module, in specific the Modal plugin. My app-folder is structured in this way:

  • app
    • scheda
      • scheda.html
      • schedacontroller.js
    • app.js
  • css
  • ...
  • index.html

This is app.js, the main app file:

// created the module GasistaFelice
// also included ngRoute for all our routing needs

angular.module('ngGasistaFelice', [])
.run(function($rootScope) {
    $rootScope.gasID = "10"; //default value

angular.module('ngGasistaFelice', ['ui.bootstrap']);

var GasistaFelice = angular.module('ngGasistaFelice', ['ngRoute']);

GasistaFelice.config(['$routeProvider',function($routeProvider) {
// route for the home page
            .when('/', {
                templateUrl : 'app/ordinare/ordinare.html',
                controller  : 'orderController'

            // route for the paniere page
            .when('/:id/gasmember/:id/basket', {
                templateUrl : 'app/paniere/paniere.html',
                controller  : 'paniereController'

            // route for the scheda page
            .when('/:id/profile', {
                templateUrl : 'app/scheda/scheda.html',
                controller  : 'schedaController'

            // route for the conto page
            .when('/:id/gasmember/:id/cash', {
                templateUrl : 'app/conto/conto.html',
                controller  : 'contoController'
                    redirectTo: '/'


This is the controller of the page in which i want to put the Modal plugin:

var app = angular.module('ngGasistaFelice', ['ui.bootstrap']);
app.controller('schedaController', function ($scope, $routeParams, $modal, $log, $http) {
        var id = $;
        // --- URL finale --- 
        //var url = 'http://localhost:8000/gasistafelice/api/v1/person/id/?format=json';
        //URL di prova

        $scope.items = ['item1', 'item2', 'item3'];

          $ = function (size) {

            var modalInstance = ${
              templateUrl: 'myModalContent.html',
              controller: ModalInstanceCtrl,
              size: size,
              resolve: {
                items: function () {
                  return $scope.items;

            modalInstance.result.then(function (selectedItem) {
              $scope.selected = selectedItem;
            }, function () {
              $'Modal dismissed at: ' + new Date());

When i load the page containing the schedaController, i keep getting this error:

Error: [$injector:unpr] h ttp://$injector/unpr?p0=%24routeParamsProvider%20%3C-%20%24routeParams
    at Error (native)
    at http://localhost/GasistaFelice2_angular/js/angular.min.js:6:450
    at http://localhost/GasistaFelice2_angular/js/angular.min.js:35:431
    at Object.c [as get] (http://localhost/GasistaFelice2_angular/js/angular.min.js:34:13)
    at http://localhost/GasistaFelice2_angular/js/angular.min.js:35:499
    at c (http://localhost/GasistaFelice2_angular/js/angular.min.js:34:13)
    at d (http://localhost/GasistaFelice2_angular/js/angular.min.js:34:230)
    at Object.instantiate (http://localhost/GasistaFelice2_angular/js/angular.min.js:34:394)
    at http://localhost/GasistaFelice2_angular/js/angular.min.js:66:112
    at http://localhost/GasistaFelice2_angular/js/angular.min.js:53:14

Thank you

Problem courtesy of: Dyd666


You're defining angular.module('ngGasistaFelice', []) multiple times with different required modules (inside of the second parameter to the module function):

angular.module('ngGasistaFelice', [])
angular.module('ngGasistaFelice', ['ui.bootstrap']);
var GasistaFelice = angular.module('ngGasistaFelice', ['ngRoute']);
var app = angular.module('ngGasistaFelice', ['ui.bootstrap']);

...specifically, the last one is the one you're trying to use ngRoute with, and you haven't even injected it there.

A better solution is to define it once, say:

var GasistaFelice = angular.module('ngGasistaFelice', [

And then you could do what you were trying to do:


Or, if you need this in another file (or scope) and GasistaFelice is not yet defined, you can get it by calling angular.module without passing the required dependencies, like:

var app = angular.module('ngGaistaFelice');
Solution courtesy of: Tom


Since version 0.14.0 angular team prefixed all components you have to use, look more. For your case you need Change: $modal for $uibModal. Change: $modalInstance for $uibModalInstance. Change: modal-transclude for uib-modal-transclude

Discussion courtesy of: IgorBeaz

This recipe can be found in it's original form on Stack Over Flow.