Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to inject $scope object to the dialog template?

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

like image 764
Yahya KACEM Avatar asked Mar 09 '13 14:03

Yahya KACEM


1 Answers

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.

like image 74
pkozlowski.opensource Avatar answered Oct 22 '22 20:10

pkozlowski.opensource