2
votes

Trying to built a modal with angularjs and ui-bootstrap:

Version

  • Angularjs and its component is 1.5.3

  • ui-bootstrap-tpls-1.3.3.js.

In main app file I have included 'ui.bootstrap' as

var App = angular.module('aotaApp', ['ui.router','ui.bootstrap','checklist-model','ngSanitize'])
.controller("myController", function($scope,$state, $http)

In StatusService I am using this as

App.service("StatusModalService", ["$uibModal",
                          function ($uibModal) {
     var modalDefaults = {
         backdrop: true,
         keyboard: true,
         modalFade: true,
         templateUrl: 'resources/template/modal/confirmationModal.html'
     };
    var modalOptions = {
         closeButtonText: 'Close',
         actionButtonText: 'OK',
         headerText: 'Proceed?',
         bodyText: 'Perform this action?'
     };

     this.showModal = function (customModalDefaults, customModalOptions) {
         if (!customModalDefaults) customModalDefaults = {};
         customModalDefaults.backdrop = 'static';
         return this.show(customModalDefaults, customModalOptions);
     };

     this.show = function (customModalDefaults, customModalOptions) {
         //Create temp objects to work with since we're in a singleton service
         var tempModalDefaults = {};
         var tempModalOptions = {};

         //Map angular-ui modal custom defaults to modal defaults defined in service
         angular.extend(tempModalDefaults, modalDefaults, customModalDefaults);

         //Map modal.html $scope custom properties to defaults defined in service
         angular.extend(tempModalOptions, modalOptions, customModalOptions);

         if (!tempModalDefaults.controller) {
             tempModalDefaults.controller = function ($scope, $uibModalInstance) {
                 $scope.modalOptions = tempModalOptions;
                 $scope.modalOptions.ok = function (result) {
                     $uibModalInstance.close(result);
                 };
                 $scope.modalOptions.close = function (result) {
                     $uibModalInstance.dismiss('cancel');
                 };
             }
         }

         return $uibModal.open(tempModalDefaults).result;
     };
 }]);

But I am getting error

angular-1.5.3.js:13424 Error: [$injector:unpr] Unknown provider: $uibModalProvider <- $uibModal <- StatusModalService

I am new to angular and mainly found to add ui.bootstrap in app. but it's not giving any help.

Please guide me.

3
Here's a plunk with your code plnkr.co/edit/cXxZiWjcbNJ8t5p4CmyG?p=preview It isn't blowing any errors. Check the versions to see if yours are different.jbrown

3 Answers

0
votes

It seems like a version issue, Need to upgrade your ui-bootstrap

https://github.com/compact/angular-bootstrap-lightbox/issues/42

0
votes

Install latest version of angular-bootstrap

npm install angular-bootstrap or bower install angular-bootstrap
0
votes

This could also be due to a renaming of $uibModal. If you have this error, try using $modal instead.