Question

I have this plunker with a dialog example that uses the resolve attribute of the option object, based on this example.
Basically what I want to do is to pass the title variable to be used in the dialog template:

var title         = "azerty";

Using the resolve attribute of the dialog options object:

resolve:       {title: angular.copy(title)}

And then inject it to the dialog controller and assign it to a $scope variable:

controllers.DialogController = function($scope, dialog, title) {
    $scope.title = title;

But I get this Error:

Error: Unknown provider: azertyProvider <- azerty

Was it helpful?

Solution

Starting with release 0.2.0 (https://github.com/angular-ui/bootstrap/blob/master/CHANGELOG.md#020-2013-03-03) we've updated the resolve syntax so it follows the one used by the $routeProvider. In practice it means that a value in the resolve object must be a function:

resolve: {
  title: function() {
    return angular.copy(title);
  }
}

Here is the working plunk: http://plnkr.co/edit/qmNUsWK7RGeAjXcANuWv?p=preview

BTW, you don't need (and even should not) include Bootstrap's JavaScript. This project doesn't have dependencies on any external JavaScript (beside AngularJS itself) so you don't need jQuery either.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top