Uncaught Error: Unknown provider: $templateRequestProvider <- $templateRequest <- $modal

E Sturzenegger picture E Sturzenegger · May 15, 2015 · Viewed 9.5k times · Source

Hello Stackoverflowers ;)

I struggle for a bit of time on this particular problem concerning the bootstrap.ui modal:

Uncaught Error: Unknown provider: $templateRequestProvider <- $templateRequest <- $modal

I tried already to define a provider but I can't get it to work properly.

This is my app.js:

var app = angular.module('stelping', ['ui.bootstrap']).
config(['$routeProvider', function ($routeProvider) {
    $routeProvider.
        when('/', {
            templateUrl: 'pages/home.html',
            controller: HomeCtrl,
            activetab: 'home'
        }).
        when('/notentool', {
            templateUrl: 'pages/notentool.html',
            controller: NotentoolCtrl,
            activetab: 'notentool'
        }).
        when('/lerngruppe', {
            templateUrl: 'pages/lerngruppe.html',
            controller: LerngruppenCtrl,
            activetab: 'lerngruppe'
        }).
        when('/raumreservierung', {
            templateUrl: 'pages/raumreservierung.html',
            controller: RaumreservierungCtrl,
            activetab: 'raumreservierung'
        }).
        when('a', function() {
            return {
                restrict: 'E',
                link: function(scope, elem, attrs) {
                    if(attrs.ngClick || attrs.href === '' || attrs.href === '#'){
                        elem.on('click', function(e){
                            e.preventDefault();
                        });
                    }
            }
        }}).
        when('/registrieren', {
            templateUrl: 'pages/registrieren.html',
            controller: RegistrierungsCtrl,
            activetab: 'registrieren'
        }).
        otherwise({ redirectTo: '/' });
}]).run(['$rootScope', '$modal', '$log', '$http', '$browser', '$timeout', "$route", function ($scope, $modal, $log, $http, $browser, $timeout, $route) {

    $scope.$on("$routeChangeSuccess", function (scope, next, current) {
        $scope.part = $route.current.activetab;
    });


}]);

app.config(['$locationProvider', function($location) {
    $location.hashPrefix('!');
}]);

And this is my controller.js (partially only the two new Ctrls):

function LerngruppenCtrl($scope, $modal, $log) {
$scope.buildings = [ 1, 5, 6 ];
$scope.rooms = [ 0, 1, 2, 3, 4 ];
$scope.currentBuilding = 1;
$scope.currentRoom = 0;
$scope.setRoom = function(room) {
    $scope.currentRoom = room;
}
$scope.setBuilding = function(building) {
    $scope.currentBuilding = building;
}
$scope.imgChanger = function() {
    return $scope.currentBuilding+"_"+$scope.currentRoom;
};
$scope.class = "hidden";

$scope.open = function (size) {

    var modalInstance = $modal.open({
        templateUrl: 'myModalContent.html',
        controller: 'ModalInstanceCtrl',
        size: size
    });
    modalInstance.result.then(function () {
        $log.info('Modal dismissed at: ' + new Date());
    });
};
}

function ModalInstanceCtrl($scope, $modalInstance) {
    $scope.cancel = function () {
        $modalInstance.dismiss('cancel');
    };
}

Answer

Dylan Watt picture Dylan Watt · May 15, 2015

That error is due to a mismatch between the versions of ui.bootstrap and angular. ui.bootstrap .13 depends on 1.3x, .12 depended on 1.2x.