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');
};
}
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.
I also have same problem. I solved it by using latest version of angularjs, ui-bootstrap I have used these version:
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.4.4/angular.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.4.4/angular-animate.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.4.4/angular-route.min.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/angular-ui-bootstrap/0.13.3/ui-bootstrap-tpls.min.js"></script>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With