0

I want to create simple pop-up dialog in AngularJS using bootstrap-ui's $dialog directive.

I get $dialog undefined, when I try to inject into my controller. Can someone provide hint on "How to properly inject $dialog" into the following design and invoke it to create a pop-up dialog?

Thanks in advance

index.js:

angular.module('myapp', ['myapp.core','myapp.templates','ui.router', 'ui.bootstrap',
  'angularChart', 'angularjs-dropdown-multiselect', 'smart-table', 'angularModalService']);

Page Controller:

(function() {
  'use strict';
  angular.module('myapp').controller('Page3Controller', Page3Controller);
  function Page3Controller(
    $scope,
    $dialog, // undefined
    Page3Service,
    Utility) {
Tom
  • 7,640
  • 1
  • 23
  • 47
tennis
  • 91
  • 1
  • 8

2 Answers2

1

As the accepted answer of this post says, The $dialog service was refactored into $modal for version 0.6.0 of ui-bootstrap. The functionality from $dialog should still be available, just through $modal instead.

inject the $modal service within your module and it should work. Read the docs

So, to edit your code,

 (function() {
      'use strict';
      angular.module('myapp').controller('Page3Controller', Page3Controller);
      function Page3Controller(
        $scope,
        $modal, // now do with it whatever you want, refer to the docs for detailed change
        Page3Service,
        Utility) {

Please check if it is working this way.

Community
  • 1
  • 1
Suman Barick
  • 3,311
  • 2
  • 19
  • 31
  • I can inject $modal, however when I try to follow the suggestion from the docs I get error stating 'ModalInstanceCtrl' not defined. I have it in a separate .js file instanceControl.js file. – tennis Jul 14 '15 at 17:30
  • You should import the file holding this second cotnroller (for example loading it via – endamaco Jul 14 '15 at 17:35
0

Controller:

(function(){
    angular.module("myApp").controller("Page3Controller", ["$scope", 
        "$dialog", "Page3Service", "Utility", Page3Controller]);

        function Page3Controller($scope, $dialog, Page3Service, Utility){
            $dialog.whatEverYouNeedToDo();

        }
});
Teliren
  • 342
  • 1
  • 5