0

我正在做一个带有角度材料的小项目,我正在使用 mdDialog,所以每次我关闭对话框时,视图都是不可点击的。我认为问题是对话框在 DOM 中注入的位置?

我对所有对话框都使用相同的控制器(功能不多)

这是对话框的 html 之一:

<md-dialog aria-label="Attention Information" class='custom-dialog info-task-dialog'>
  <md-dialog-content>
    <md-card>
      <md-toolbar>
        <div class="md-toolbar-tools">
          <h2>Attention Information</h2>
          <span flex></span>
          <md-button class="md-icon-button" ng-click="hideDialog()">
            <md-icon class="close-dialog" md-svg-src="../../img/close.svg" aria-label="Close dialog"></md-icon>
          </md-button>
        </div>
      </md-toolbar>
      <md-dialog-content>
        <div class="md-dialog-content">

          <span class='md-caption'>
            <strong>Customer Name: </strong>{{ attentionInfo.CustomerName }}
          </span>

          <p class='md-caption'>
            <strong>Reason: </strong>{{ attentionInfo.Reason }}
          </p>

          <p class='md-caption'>
            <strong>If they open a case: </strong>{{ attentionInfo.If }}
          </p>

          <p class='md-caption'>
            <strong>Please revise again on: </strong>{{ attentionInfo.Revise }}
          </p>


        </div>
      </md-dialog-content>

    </md-card>
  </md-dialog-content>
</md-dialog>

这是打开对话框和控制器的代码:

$scope.openAddTaskDialog = function($event){
      actionType = 'add';

      $mdDialog.show({
        parent: angular.element(document.body.getElementsByClassName('task-container')),
        targetEvent: $event,
        templateUrl: 'templates/tasks/addtask.html',
        controller: MoreTaskController,
        scope: $scope,
        clickOutsideToClose:true
      })
      .then(function() {
      }, function() {
      });
    }

    $scope.openTaskInfo = function($event) {
      actionType = 'info';

      $mdDialog.show({
        parent: angular.element(document.body.getElementsByClassName('task-container')),
        targetEvent: $event,
        templateUrl: 'templates/tasks/moretask.html',
        controller: MoreTaskController,
        scope: $scope,
        clickOutsideToClose:true
      })
      .then(function() {
      }, function() {
      });
    };

    $scope.openTaskEdit = function ($event) {
      actionType = 'edit';

      $mdDialog.show({
        parent:  angular.element(document.body.getElementsByClassName('task-container')),
        targetEvent: $event,
        templateUrl: 'templates/tasks/edittask.html',
        controller: MoreTaskController,
        scope: $scope,
        clickOutsideToClose:true
      })
      .then(function() {
      }, function() {
      });
    };

    function MoreTaskController($scope, $mdDialog) {
      switch (actionType){
        case 'edit':
        $scope.editTask = taskChosen;
        $scope.editTask.Until = moment(new Date(moment(taskChosen.Until, "YYYY/MM/DD HH:mm"))).format('DD/MM/YYYY HH:mm');
        console.log($scope.editTask.Until);
        break;

        case 'add':
        $scope.newTask = {
          SFNumber: '',
          PartnerName: '',
          Until: '',
          Class: '',
          Action: ''
        }

        break;

        case 'info':
        $scope.taskInfo = taskChosen;
        break;
      }

      $scope.customerClasses = ['Gold', 'Silver', 'Platinum'];

      $scope.AddTask = function(){
        $scope.newTask.Until = $scope.taskForm.field.$modelValue;

        TasksService.AddTask($scope.newTask, function(response){
          if (response.success && response.data === "1"){
            $scope.GetOpenTasks();
            $scope.hideDialog();
          } else {
            // ErrorAlert();
          }
        });
      }

      $scope.UpdateTask = function(){
        $scope.editTask.Until = $scope.taskForm.field.$modelValue;

        TasksService.UpdateTask($scope.editTask, function(response){
          if (response.success && response.data === "1"){
            $scope.GetOpenTasks();
            $scope.hideDialog();
          } else {
            // ErrorAlert();
          }
        });
      }

      $scope.hideDialog = function() {
        $mdDialog.hide();
      };
    }

感谢您的每一个微小帮助!

4

0 回答 0