title: Reset form when i click modal pop up close button (x) in Angularjs
body: <p>I have form in modal pop up.i am using directives for opening the modal pop up </p>
  
  <pre><code>mymodule.directive('modalDialogSite', function() {
    return {
      restrict: 'E',
      scope: {
        show: '='
      },
      replace: true, // Replace with the template below
      transclude: true, // we want to insert custom content inside the directive
      link: function(scope, element, attrs) {
        scope.dialogStyle = {};
        if (attrs.width)
          scope.dialogStyle.width = attrs.width;
        if (attrs.height)
          scope.dialogStyle.height = attrs.height;
          if (attrs.overflow)
          scope.dialogStyle.overflow = attrs.overflow;
        scope.hideModal = function() {
          scope.show = false;
        };
      },
      template: "&lt;div class='ng-modal' ng-show='show'&gt;&lt;div class='ng-modal-overlay'&gt;&lt;/div&gt;&lt;div class='ng-modal-dialog' ng-style='dialogStyle'&gt;&lt;div class='ng-modal-close' ng-click='hideModal()'&gt;&lt;i class='fa fa-times-circle'&gt;&lt;/i&gt;&lt;/div&gt;&lt;div class='ng-modal-dialog-content' ng-transclude&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;"// See below
    };
  });
  </code></pre>
  
  <p>If i click cancel button in modal popup i use $setpristine to reset the form but If have any validation error when i click close button (x) it calls hideModal() function so modal get closed but if i reopen the modal pop the validation error still exists in modal popup.How can i reset that form.Here My working Plnkr <a href="https://plnkr.co/edit/embFJFmautH3uRbHOWU7?p=preview" rel="nofollow noreferrer">https://plnkr.co/edit/embFJFmautH3uRbHOWU7?p=preview</a></p>