2

Whatever I try to do I can't seem to pass data to a modal controller.

I tried using resolve:

   var opts = {
        backdrop: true,
        keyboard: true,
        backdropClick: true,
        templateUrl:  'views/details/basic/view.html',
        controller: 'BoxDetailsCtrl'
        resolve: {
            item: function () {
                return angular.copy(item)
            },
            price: function (){ return 100; }
        }

        this.d = this.d || $dialog.dialog($scope.opts);
        this.d.open();

I tried passing the scope:

     var opts = {
        scope: $scope
        ...

In my dispair I event tried hacking the dialog service:

 if (self.options.controller) {
                    var ctrl = $controller(self.options.controller, locals);
                    ctrl.modal = self.options.modal; // nasty hack
                    self.modalEl.children().data('ngControllerController', ctrl);
           }

Nothing worked. I can't seem to be able to pass data to BoxDetailsCtrl. Any ideas?

Cheers,

Guy
  • 12,488
  • 16
  • 79
  • 119
  • 1
    I'm struggling through a similar problem and found your unanswered question. It might help if you include the instantiation of BoxDetailsCtrl in your question. I'm having problems passing locals to a controller declared with Module.controller(...) and I think it has to do with that. – divestoclimb Oct 02 '13 at 20:12

1 Answers1

0

This method is working for me ... it's in coffeescript but you can convert it to js.

AngularUI separate files for modal controllers

resolve:
       primer3: ->
         $scope.primer3

Then

angular.module('assaypipelineApp').controller "ConfigureModalCtrl", ($scope,  $modalInstance, primer3) ->
  $scope.primer3 = primer3['data']

I found I was getting an object with the data array embedded and with the http return code. I don't really understand why, but this works.

I hope that helps.

Community
  • 1
  • 1
port5432
  • 5,889
  • 10
  • 60
  • 97