Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular UI: Unknown provider: dialogProvider

I am trying to replicate the following Angular UI example of a simple dialog with a close-button. https://github.com/angular-ui/bootstrap/blob/master/src/dialog/README.md. However, I cannot get the dialog parameter to be injected properly into my dialog controller.

The controllers looks like below (using CoffeScript)

angular.module('myApp', ['ui.bootstrap'])

angular.module('myApp').controller 'MyController', ($dialog, $scope) ->
  $dialog.dialog().open('dialogTemplate', 'DialogController')

angular.module('myApp').controller 'DialogController', ['$scope', 'dialog', ($scope, dialog) ->
    $scope.close = -> dialog.close()
]

See the Plunker for a live version: http://plnkr.co/edit/ejKh7w8Sk9H7Nz3rXhdc?p=preview

Angular gives me the following error:

Unknown provider: dialogProvider <- dialog

Any ideas on how the dialog-parameter could be injected into DialogController, as is seen in the docs example referred to above? I suspect this could have something to do with CoffeeScript since I am fairly new to this language, but it seems quite right when I look at the compiled output.

like image 415
nip3o Avatar asked Apr 25 '13 22:04

nip3o


1 Answers

I had a similar problem and was struggling to find a solution.

I was expecting two additional arguments to my controller; ..., selectedView, dialog). It seemed to provide my dialog with the right arguments, but I still got an error in the console.

The problem was that I was referencing the controller twice;

  1. When opening my dialog: dialog.open('template', 'myController')
  2. In my template file: section(ng-controller='myController')

Removing (2) resolved the problem, since that wasn't invoked by the dialog code, which provided my selectedView argument and the default dialog argument.

Hope that helps someone.

like image 173
Kristofer Sommestad Avatar answered Sep 21 '22 12:09

Kristofer Sommestad