我想展示一个dialog
来自 angularjs的内容controller
。我正在使用angular-ui和angular-strap
在控制器中注入 $dialog 时出现以下错误:
Error: [$injector:unpr] http://errors.angularjs.org/1.2.0rc1/$injector/unpr?p0=%24dialogProvider%20%3C-%20%24dialog
at Error (<anonymous>)
at https://ajax.googleapis.com/ajax/libs/angularjs/1.2.0rc1/angular.min.js:6:450
at https://ajax.googleapis.com/ajax/libs/angularjs/1.2.0rc1/angular.min.js:31:145
at Object.c [as get] (https://ajax.googleapis.com/ajax/libs/angularjs/1.2.0rc1/angular.min.js:28:296)
at https://ajax.googleapis.com/ajax/libs/angularjs/1.2.0rc1/angular.min.js:31:213
at c (https://ajax.googleapis.com/ajax/libs/angularjs/1.2.0rc1/angular.min.js:28:296)
at d (https://ajax.googleapis.com/ajax/libs/angularjs/1.2.0rc1/angular.min.js:28:473)
at Object.instantiate (https://ajax.googleapis.com/ajax/libs/angularjs/1.2.0rc1/angular.min.js:30:123)
at https://ajax.googleapis.com/ajax/libs/angularjs/1.2.0rc1/angular.min.js:58:153
at https://ajax.googleapis.com/ajax/libs/angularjs/1.2.0rc1/angular.min.js:46:383
我的 ApplicationResources.groovy
angularJs { resource url:'https://ajax.googleapis.com/ajax/libs/angularjs/1.2.0rc1/angular.min.js' }
angularUI {
dependsOn 'angularJs'
dependsOn 'jquery'
dependsOn 'googleMaps'
resource url:'https://cdnjs.cloudflare.com/ajax/libs/angular-ui/0.4.0/angular-ui.min.css',attrs:[rel: "stylesheet", type:'css']
resource url:'https://cdnjs.cloudflare.com/ajax/libs/angular-ui/0.4.0/angular-ui.min.js'
resource url:'https://cdnjs.cloudflare.com/ajax/libs/angular-ui/0.4.0/angular-ui-ieshiv.min.js'
}
angularStrap {
dependsOn 'angularJs'
dependsOn 'bootstrapJs'
dependsOn 'datepicker'
resource url: 'https://cdnjs.cloudflare.com/ajax/libs/angular-strap/0.7.4/angular-strap.min.js'
resource url: 'js/angular-strap/datepicker.js'
resource url: 'js/angular-strap/timepicker.js'
}
userJs { resource url:'js/user.js' }
我的用户.gsp
<html ng-app="user">
<r:require modules="bootstrapJs" />
<r:require modules="userJs" />
<r:require modules="angularJs" />
</html>
我使用 angular-ui 的 ui.bootstrap.dialog 的 EncouragementController.js 是
function EncouragementController($scope, $http, $dialog, encouragementService) {
//
$scope.showMessage = function(message){
var title = 'Alert';
var msg = message;
var btns = [{result:'cancel', label: 'Cancel'}, {result:'ok', label: 'OK', cssClass: 'btn-primary'}];
$dialog.messageBox(title, msg, btns)
.open()
.then(function(result){
});
};
}
EncouragementController.$inject = [ '$scope', '$http', '$dialog', 'encouragementService' ];
我的 app.js
var user = angular.module('user', [ 'ui', '$strap.directives' ]);
我关注了angular js unknown provider,但那里没有对我有用的答案。