title: Clear contents of modal window on close or show in angularjs
body: <p>I just started with Angular JS recently and ran into some issue with modal dialogs.
  I have a very simple problem, all I want is the two text input fields inside the modal window to clear themselves when the modal window either closes or opens.
  The text fields on modal are binded with <code>newPlan.Name</code> and <code>newPlan.Description</code> </p>
  
  <p>I created the following method in controller to clear the fields:</p>
  
  <pre><code>$scope.ClearForm = function() {
          $scope.newPlan = {};
      }
  </code></pre>
  
  <p>if I invoke this method by ng-click of a button, then text fields erase themselves but when I invoke this method on hide/show/hidden/shown event of the modal then the fields do not clear their text but something interesting happens, as soon as I start typing in one input field, the other one becomes empty.</p>
  
  <p>this is how I am clearing the fields on modal hide event.</p>
  
  <pre><code> $('#AddLeavePlanWindow').on('hide.bs.modal', function() {
    angular.element("#AppElement").scope().ClearForm();
   });
  </code></pre>
  
  <p>where <code>#AppElement</code> is the element in html on which ng-app and ng-controller tags are specified.
  Here is the JSFiddle link <a href="https://jsfiddle.net/9kxdj3vv/67/" rel="nofollow noreferrer">https://jsfiddle.net/9kxdj3vv/67/</a></p>
  
  <p>In my opinion, something weird happens when the modal closes/opens and at the same time Angular changes the values, although the values are changed but they don't reflect on UI. But when the modal stays open, it works just fine.</p>
  
  <p>I do not want to call the <code>ClearForm();</code> method on Close Button because I want to be able to click anywhere on screen to close the modal and still have it clear the fields hence using <code>.on('hide.bs.modal'</code> I am open to use <code>hidden/show/shown</code></p>
  
  <p>One might also point out that I shouldn't be using Angular and jQuery at the same time, they are correct but I don't think thats the problem right now, I will move to Angular completely but first I need to know whats going wrong here and why is it not working.</p>
  
  <p>I appreciate all the help,
  Thanks in advance.</p>