我正在尝试使用angular bootstrap中的模态服务:
<script src="bower_components/angular/angular.min.js"></script>
<script src="bower_components/angular-bootstrap/ui-bootstrap.min.js"></script>
<script src="js/index.js"></script>
我的应用控制器( index.js ):
var app = angular.module('emaApp', ['ui.bootstrap']);
app.controller('mainCtrl', ['$scope', '$http', '$modal', function($scope, $http, $modal) {
// ...
}]);
但是,我没有超出此错误消息,我也不知道问题所在:
jquery.min.js:2 Uncaught Error: [$injector:modulerr] http://errors.angularjs.org/1.6.1/$injector/modulerr?p0=emaApp&p1=Error%3A%…host%3A8080%2Fweb%2Fbower_components%2Fangular%2Fangular.min.js%3A21%3A332)
at angular.js:38
at angular.js:4759
at q (angular.js:357)
at g (angular.js:4720)
at eb (angular.js:4642)
at c (angular.js:1838)
at Mc (angular.js:1859)
at pe (angular.js:1744)
at HTMLDocument.<anonymous> (angular.js:32977)
at j (jquery.min.js:2)
答案 0 :(得分:1)
您必须加载此脚本:
<script src="..path_to_script../ui-bootstrap-tpls.js"></script>
答案 1 :(得分:1)
使用模态注入$uibModal
您的控制器将是:
app.controller('mainCtrl', ['$scope', '$http', '$uibModal', function($scope, $http, $uibModal) {
// ...
}
答案 2 :(得分:0)
您没有正确关闭控制器
而不是这个
app.controller('mainCtrl', ['$scope', '$http', '$modal', function($scope, $http, $modal) {
// ...
}
使用此
app.controller('mainCtrl', ['$scope', '$http', '$modal', function($scope, $http, $modal) {
// ...
}]);