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.
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;
dialog.open('template', 'myController')
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With