0

when i close the ngdialog popup after checking the checkbox which is inside of it, and again if i open it then the checkbox is getting unchecked, why is it happening do anybody know that? this is my script tag

    <script type="text/ng-template" id="templateId">

    <div id="target" ng-click="test()" ng-controller="tt">
      Click here
      <input type='checkbox' placeholder=''>
    </div>
</script>

this is my example jsfiddle http://jsfiddle.net/mb6o4yd1/264/

Syed Rasheed
  • 559
  • 2
  • 10
  • 29

3 Answers3

1

It seems that this ngDialog module destroys the controller after it is closed. If you want to access and keep the changes in your controller. Use $parent from your controller.

I've created this fiddle for you.

<script type="text/ng-template" id="templateId">
  <div id="target" ng-click="test()">
    Click here
  <input type='checkbox' ng-model="$parent.checkbox">
</div>

OR

Using your approach you have to save the values into a factory before leaving the dialog

Hope it helps.

M. Junaid Salaat
  • 3,765
  • 1
  • 23
  • 25
0

You need to declare a model on your checkbox, eg:

Then you need to copy that value to the scope of you choosing when the dialog is closed, so that when the modal dialog is opened again, it can access that value (provided it is available). The scope of the modal dialog will be disposed when the dialog is closed, so you cannot save its state there.

Carl
  • 1,266
  • 10
  • 20
0

Bind a model which holds the checkbox value and have it in your parent controller. This would fix your issue.

Nagaraj
  • 221
  • 2
  • 5
  • 21