2

What I am trying is, to disable the action of close in ng-dialog pop up until any other button is clicked.I want to do that until I give some text on input in pop up and click on save button the pop up should not be closed either by into (*) mark

Yogeshree Koyani
  • 1,649
  • 10
  • 19
Vindya Veer
  • 139
  • 1
  • 3
  • 15

2 Answers2

4

Suppose you have a template of pop up like below :

<button type="button" ng-click="closeThisDialog('button')" ng-disabled="demoForm.$invalid" class="btn btn-default pull-right">x</button>
<br>
<form name="demoForm">
  <h3>Close button disabled untill no input</h3>
  <p>Here input field is required so untill input box is not valid you cannot close the dialoug.</p>
  <p>Once you enter the input close btn will be enabled</p>
  <input ng-model="confirmValue" required/>
  <br>
  <br>
  <button type="button" ng-disabled="demoForm.$invalid" ng-click="closeThisDialog('button')" class="btn btn-default">Cancel</button>
  <button type="button" class="btn btn-default">Save</button>
</form>

You can add form in your pop-up template just shown in above template.

Now as per your requirement user should not close the popup until he didn't enter any input so there is validation in form.

Just disable close button until form is not valid.

Check out this demo

You can refer more here in doc of ng-dialog.

Satyam Koyani
  • 4,236
  • 2
  • 22
  • 48
Yogeshree Koyani
  • 1,649
  • 10
  • 19
1

the easiest way of having control over ngDialog via buttons is to change the default boolean of closeByDocument and showClose to false. Then you can only use buttons to exit.

Stuck-Over-Flow
  • 75
  • 1
  • 10