In my project, I have a modal that prompts the user to enter some input. The logic of the code is structured as follows:
When the user clicks on the 'Add' button, a modal window appears asking for input. After entering the input, the user clicks 'okay'.
On the controller side, the following code snippet shows the functionality:
$scope.ok = function() {
if (entered_value == 'disk') {
//perform some actions
$uibModalInstance.close(); //this closes the modal
}
else {
// perform some actions
$uibModalInstance.close();
}
}
Under normal conditions, this code works fine - executing different actions based on user input ('disk' or anything else).
However, a problem arises when repeatedly clicking 'okay' and entering user values. For example:
- First click on 'Add', enter 'data' as input, and the modal closes.
- Second click on 'Add', enter 'asa' as input, but the modal does not close because
$uibModalInstance.close()
was already executed previously.
To address this issue and ensure the modal closes each time, any advice or suggestions would be greatly appreciated. Thank you!