3

I use https://github.com/simpulton/angularjs-wizard for my project, it works, (I modified it a little, replaced var app to $scope)

but I need to pass a variable to open function:

$scope.open = function (image)
    {
        $scope.image = image;

        var modalInstance = $uibModal.open({
            templateUrl: 'wizard.html',
            controllerAs: 'modal',
            size: 'lg',
            controller: 'ModalCtrl',
            resolve: {
                image: function () {
                    return image;
                }
            }
        });

        modalInstance.result
            .then(function (data) {
                $scope.closeAlert();
                $scope.summary = data;
            }, function (reason) {
                $scope.reason = reason;
            });
    };

and in html:

ng-click="open(image)"

but image is undefined in my template

it works if I only just the modal window, with the example from https://angular-ui.github.io/bootstrap/#/modal, but not with this wizard example

update:

https://jsfiddle.net/Ginstay/znz64sk3/2/

yes, ajax is completed at the moment, when I open the modal window

and if I add a breakpoint to return image; image is there

7
  • Can you create a jsfiddle? It's hard to catch where problem is/ Commented Mar 25, 2016 at 6:44
  • Try passing an image url in ng-click="open('urlofimage.com')" Commented Mar 25, 2016 at 6:45
  • it's not an url, it's an object, retrieved with ajax request because of the same reason, I'm not how I can make a jsfiddle, but I'll try now Commented Mar 25, 2016 at 6:47
  • could you please add ModalCtrl code? Commented Mar 25, 2016 at 6:48
  • @lasoweq is your image already retrieved by an ajax request when you try to open the modal? The AJAX might still not be processed. Commented Mar 25, 2016 at 6:52

2 Answers 2

5

Try this one

angular.module('plunker', ['ui.bootstrap']);
var ModalDemoCtrl = function ($scope, $modal) {

var modalInstance = $modal.open({
  templateUrl: 'myModalContent.html',
  controller: ModalInstanceCtrl,
  resolve: {
    test: function () {
      return 'test variable';
    }
  }
});
};

var ModalInstanceCtrl = function ($scope, $modalInstance, test) {
  $scope.test = test;
};
Sign up to request clarification or add additional context in comments.

Comments

1

I figured it, I needed to add

$scope.image = image;

to ModalCtrl

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.