title: Angular-material, $mdDialog
body: <p>Not closed mddialog when calling it from another mddialog.</p>
  
  <p>It is html:</p>
  
  <pre><code>&lt;some-auth&gt;
    &lt;md-button  ng-click="showSign('', $event)" flex-sm="100" flex-md="100" 
    flex-gt-md="auto"&gt;Sign In&lt;/md-button&gt;
  &lt;/some-auth&gt;
  </code></pre>
  
  <p>In controller:</p>
  
  <pre><code>$scope.showSign = function(typeUrl, ev) {
      $mdDialog.hide().then(function(){
        var templateUrl = 'login.html';
        if (typeUrl.indexOf('signup') &gt; -1) {
          templateUrl = 'register.html';
        } else if (typeUrl.indexOf('resetpasswd') &gt; -1) {
          templateUrl = 'resetpasswd.html';
        }
  
        $mdDialog.show({
          controller: DialogController,
          templateUrl: templateUrl,
          parent: angular.element(document.body),
          targetEvent: ev,
          scope: $scope,
          preserveScope: true
          clickOutsideToClose:true
        });
      });
    };
  
    function DialogController($scope, $mdDialog) {
      $scope.hide = function() {
        $mdDialog.hide();
      };
      $scope.cancel = function() {
        $mdDialog.cancel();
      };
      $scope.answer = function(answer) {
        $mdDialog.hide(answer);
  
      };
    }
  </code></pre>
  
  <p>"dialog_0" show/hide, but "dialog_1" (which is called from "dialog_0") not close any.</p>
  
  <p>in resetpasswd.html some like:</p>
  
  <pre><code>&lt;md-dialog aria-label="Resetpasswd" ng-cloak&gt;
    &lt;form name="resetForm" ng-controller="ResetController" ng-submit="reset()"&gt;
      &lt;md-toolbar&gt;
        &lt;div class="md-toolbar-tools"&gt;
          &lt;h2&gt;Reset Password&lt;/h2&gt;
          &lt;md-button type="button" class="md-icon-button" ng-click="cancel()"&gt;
            &lt;md-icon md-font-library="material-icons" aria-label="Close   dialog"&gt;close&lt;/md-icon&gt;
          &lt;/md-button&gt;
        &lt;/div&gt;
      &lt;/md-toolbar&gt;
      &lt;md-dialog-content style="max-width:800px;max-height:810px; "&gt;
        &lt;div class="md-dialog-content"&gt;
          ...
        &lt;/div&gt;
        &lt;div class="md-actions" layout="row"&gt;
          &lt;div class="modal-footer"&gt;
            &lt;md-button type="submit"&gt;Reset Password&lt;/md-button&gt;
            &lt;md-button type="button" ng-click="showSign('', $event)" flex-sm="100" flex-md="100" flex-gt-md="auto"&gt;Login
            &lt;/md-button&gt;
          &lt;/div&gt;
        &lt;/div&gt;
      &lt;/md-dialog-content&gt;
    &lt;/form&gt;
  &lt;/md-dialog&gt;
  </code></pre>
  
  <p>Login.html looks similar</p>