Abhijit Chakra Abhijit Chakra - 2 years ago 1151
AngularJS Question

Why i need to pass parameter to $uibModalInstance.close(parameter)

I am new to angular JS just trying to understand

what i understand it closes the current modal window what the
does inside the

Answer Source

When you open a modal it will return an object with several promises, one of those promises is result, this promise will be resolved when you call close with the parameter given to it.

var modalInstance = $uibModal.open({
    controller: function($uibModalInstance) {

modalInstance.result.then(function(parameter) {
    console.log(parameter); // logs 'testParameter'

A common pattern is to have a save/confirm button in your modal, and handeling the result in the result success. To cancel the action (reject the result promise) you can call $uibModalinstance.dismiss(reason)

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download