javascript - error injecting $dialog in angularjs -
i want show dialog
angularjs controller
. using angular-ui , angular-strap
while injecting $dialog in controller following error :
error: [$injector:unpr] http://errors.angularjs.org/1.2.0rc1/$injector/unpr?p0=%24dialogprovider%20%3c-%20%24dialog @ error (<anonymous>) @ https://ajax.googleapis.com/ajax/libs/angularjs/1.2.0rc1/angular.min.js:6:450 @ https://ajax.googleapis.com/ajax/libs/angularjs/1.2.0rc1/angular.min.js:31:145 @ object.c [as get] (https://ajax.googleapis.com/ajax/libs/angularjs/1.2.0rc1/angular.min.js:28:296) @ https://ajax.googleapis.com/ajax/libs/angularjs/1.2.0rc1/angular.min.js:31:213 @ c (https://ajax.googleapis.com/ajax/libs/angularjs/1.2.0rc1/angular.min.js:28:296) @ d (https://ajax.googleapis.com/ajax/libs/angularjs/1.2.0rc1/angular.min.js:28:473) @ object.instantiate (https://ajax.googleapis.com/ajax/libs/angularjs/1.2.0rc1/angular.min.js:30:123) @ https://ajax.googleapis.com/ajax/libs/angularjs/1.2.0rc1/angular.min.js:58:153 @ https://ajax.googleapis.com/ajax/libs/angularjs/1.2.0rc1/angular.min.js:46:383
my 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' }
my user.gsp
<html ng-app="user"> <r:require modules="bootstrapjs" /> <r:require modules="userjs" /> <r:require modules="angularjs" /> </html>
my encouragementcontroller.js using angular-ui's ui.bootstrap.dialog is
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' ];
my app.js
var user = angular.module('user', [ 'ui', '$strap.directives' ]);
i followed angular js unknown provider, no answer there worked me.
angularstrap not have $dialog
service. change $modal
if want use angularstrap's modal service.
angularui have $dialog
service. in order use it, must link ui.bootstrap
module app.
angular.module('user', [ 'ui', '$strap.directives', 'ui.bootstrap']);
$modal , $dialog has different apis, must decide 1 want use.
now important note angularstrap , angularui overlaps each other great deal in functionality (e.g. both provide modal service causing above confusion). there reason have use both?
Comments
Post a Comment