Ciao Stackoverflowers;)
faccio fatica per un po 'di tempo su questo particolare problema relativo alla modale bootstrap.ui:
Uncaught Error: Unknown provider: $templateRequestProvider <- $templateRequest <- $modal
Ho provato già a definire un provider ma non riesco a farlo funzionare correttamente.
Questo è il mio 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('!');
}]);
E questo è il mio controller.js (solo parzialmente i due nuovi 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');
};
}
La mia ipotesi è che le tue versioni di angolari e ui.bootstrap sono incompatibili. Sono entrambi gli ultimi? In caso contrario, su quali versioni sono attive? –
Includete i file js Bootstrap js nel vostro file HTML? Spesso mi sono imbattuto in questi errori, dove si è scoperto che ho semplicemente dimenticato di caricare il file. – AaronB
vero questo. Ho completamente dimenticato di controllare questo ... bene angolare è 1.1.15 e bootstrap ui è 0.13.0. cambiare angolare al più recente mi porterà a un nuovo problema: Errore non rilevato: [$ injector: modulerr] http://errors.angularjs.org/1.3.15/$injector/modulerr?p0=stelping&p1=Error%...gleapis. com% 2Fajax% 2Flibs% 2Fangularjs% 2F1.3.15% 2Fangular.min.js% 3A38% 3A135). Sì, aaron lo faccio, ma questo carico normalmente come dovrebbe, così gli strumenti dev mi dicono che –