0

To close modal window one should call function modal.close(result).

close(result) - a method that can be used to close a modal, passing a result

What is result here?

What is the difference between close(true), close(false), close('blah-blah')>

3
  • you can return the result of the items in the modal dialog if you need it in another controller Commented Oct 6, 2015 at 21:05
  • what items? Can you give me an example? Commented Oct 6, 2015 at 21:05
  • The docs examples show that close resolves the modal instance result promise. This basically is a way to pass data back to the original caller of the modal service from the modal controller. Inspect the example script and play with it in the plunker link Commented Oct 6, 2015 at 21:09

2 Answers 2

1

Assuming you close the modal with something :

close(something)

You can get this something in the promise $modalInstance.result:

$modalInstance.result.then(function (something) { 
    // ... 
}

See ui-bootstrap modal documentation and plunker for reference.

Sign up to request clarification or add additional context in comments.

Comments

1

You can have your result of an operation at the modal back to the controller.

 modalInstance.result.then(function (selectedItem) {
      $scope.selected = selectedItem;
    }, function () {
      $log.info('Modal dismissed at: ' + new Date());
    });
  };

Look at this plunker link

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.